Edit XML in webforms? 
Author Message
 Edit XML in webforms?

Hi,

I have a webform, which has a couple of fields

Name:
Address:
Gender:

Now, when the form is submitted. These values get read into an XML file. What i was hoping to do, is if in someway the person wants to edit this entry, he is able to do so. either directly in the table generated by the xml or it gets populated back into the form fields.

Any suggestions?

Help will be greatly appreciated.

--
Thank You,
Sean



Sat, 26 Nov 2005 23:22:38 GMT  
 Edit XML in webforms?

Hello Sean,

.NET is totally suited to working with and manipulating XML data. All you need to do is be able to get a reference to the XML file where you are storing the data:

C#

/*
This is a sample xml file:
<?xml version="1.0">
<FormData>
    <FormInput>
        <Name>Test User</Name>
        <Address>123 Anystreet</Address>
        <Gender>Male</Gender>
    </FormInput>
</FormData>
*/

using System.Xml;
using System.Web;

private string _Name;
private string _Address;
private string _Gender;

public string Name
{
    get
    {  
        return _Name;
    }
    set
    {
        _Name = value;
    }

Quote:
}

public string Address
{
    get
    {  
        return _Address;
    }
    set
    {
        _Address = value;
    }

Quote:
}

public string Gender
{
    get
    {  
        return _Gender;
    }
    set
    {
        _Gender = value;
    }

Quote:
}

public class XmlHelper
{
    public XmlHelper()
    {
        XmlDocument xDoc = new XmlDocument();
        xDoc.Load(HttpContext.Current.Server.Mappath("<location of xml file>");

        XmlNode xNode = xDoc.DocumentElement.SelectSingleNode("FormInput");
        _Name = xNode.childNodes[0].innerText;
        _Address = xNode.childNodes[1].innerText;
        _Gender = xNode.childNodes[2].innerText;
    }

Quote:
}

Anyhow, I hope this helps...

Bill P.

  Hi,

  I have a webform, which has a couple of fields

  Name:
  Address:
  Gender:

  Now, when the form is submitted. These values get read into an XML file. What i was hoping to do, is if in someway the person wants to edit this entry, he is able to do so. either directly in the table generated by the xml or it gets populated back into the form fields.

  Any suggestions?

  Help will be greatly appreciated.

  --
  Thank You,
  Sean



Sat, 26 Nov 2005 23:37:42 GMT  
 Edit XML in webforms?

Hi Bill,

Thank You for your elaborate explaination. Surely helpful.

This is my XML File

<roottag>
    <tag1-100 param1="123123" param2="0" param3="1" param4="6/10/2003 08:00 AM" param5="PENDING" />
</roottag>

' where 100 is the unique machine number

    Sub viewxmldtn()
        Try
            Dim readxmlvar
            Dim i As Integer = 0
            Dim j As Integer = 0
            Dim Doc As System.Xml.XmlDocument = New System.Xml.XmlDocument()
            ' Load XML document
            Doc.Load("c:\temp\xmldocument.xml")
            ' Select the particular node
            Dim Root As System.Xml.XmlElement = Doc.DocumentElement
            Dim nodelist = Root.SelectNodes("tag1-" & lbunique.Text)
            ' Using readxmlvar to store the contents of the XML
            readxmlvar = "<table border='1' cellpadding='3' cellspacing='0'>"
            readxmlvar = readxmlvar & "<tr><th class='text' bgcolor='#e0e0e0'>Edit</th><th class='text' bgcolor='#e0e0e0'>Param1</th><th class='text' bgcolor='#e0e0e0'>Param2</th><th class='text' bgcolor='#e0e0e0'>Param3</th><th class='text' bgcolor='#e0e0e0'>Param4</th><th class='text' bgcolor='#e0e0e0'>Param5</th></tr>"
            For i = 0 To nodelist.Count - 1
                Dim attributelist = nodelist(i).Attributes
                readxmlvar = readxmlvar & "<tr><th class='text' bgcolor='#e0e0e0'>" & <input type='radiobutton'> & "</th>" ' This is where i was wishing to be able to put a radiobutton to edit
                For j = 0 To attributelist.Count - 1
                    If j <= 5 Then
                        readxmlvar = readxmlvar & "<td class='text'>" & attributelist.Item(j).Value & "</td>"
                    End If
                Next
                readxmlvar = editxmlvar & readxmlvar & "</tr>"
            Next
            readxmlvar = readxmlvar & "</table>"
            lbdocument.Text = readxmlvar
        Catch Exc As Exception
            lbError.Text = "<b>View XML Error Message</b>: " & Exc.Message
        End Try
    End Sub

What i would like to know, how do i pass the attribute.item(i).Value to the radiobutton?

i am trying to impliment the get methods.

Thank You once again.

Regards
Sean


  Hello Sean,

  .NET is totally suited to working with and manipulating XML data. All you need to do is be able to get a reference to the XML file where you are storing the data:

  C#

  /*
  This is a sample xml file:
  <?xml version="1.0">
  <FormData>
      <FormInput>
          <Name>Test User</Name>
          <Address>123 Anystreet</Address>
          <Gender>Male</Gender>
      </FormInput>
  </FormData>
  */

  using System.Xml;
  using System.Web;

  private string _Name;
  private string _Address;
  private string _Gender;

  public string Name
  {
      get
      {  
          return _Name;
      }
      set
      {
          _Name = value;
      }
  }

  public string Address
  {
      get
      {  
          return _Address;
      }
      set
      {
          _Address = value;
      }
  }

  public string Gender
  {
      get
      {  
          return _Gender;
      }
      set
      {
          _Gender = value;
      }
  }

  public class XmlHelper
  {
      public XmlHelper()
      {
          XmlDocument xDoc = new XmlDocument();
          xDoc.Load(HttpContext.Current.Server.Mappath("<location of xml file>");

          XmlNode xNode = xDoc.DocumentElement.SelectSingleNode("FormInput");
          _Name = xNode.childNodes[0].innerText;
          _Address = xNode.childNodes[1].innerText;
          _Gender = xNode.childNodes[2].innerText;
      }
  }

  Anyhow, I hope this helps...

  Bill P.

    Hi,

    I have a webform, which has a couple of fields

    Name:
    Address:
    Gender:

    Now, when the form is submitted. These values get read into an XML file. What i was hoping to do, is if in someway the person wants to edit this entry, he is able to do so. either directly in the table generated by the xml or it gets populated back into the form fields.

    Any suggestions?

    Help will be greatly appreciated.

    --
    Thank You,
    Sean



Sun, 27 Nov 2005 00:25:23 GMT  
 Edit XML in webforms?
Try out Susan Warren's XML Edit Grid control for starters and see if it does
some of what you need:

http://asp.net/ControlGallery/ControlDetail.aspx?Control=12&tabindex=2

HTH,
Dan Wahlin

Wahlin Consulting
Microsoft MVP - ASP.NET and XML Web Services
http://www.xmlforasp.net


Hi,

I have a webform, which has a couple of fields

Name:
Address:
Gender:

Now, when the form is submitted. These values get read into an XML file.
What i was hoping to do, is if in someway the person wants to edit this
entry, he is able to do so. either directly in the table generated by the
xml or it gets populated back into the form fields.

Any suggestions?

Help will be greatly appreciated.

--
Thank You,
Sean



Sat, 03 Dec 2005 14:52:05 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. editing xml documents using vb.net

2. XMLSpy-like VB control for editing XML

3. Editing XML Persistent recordset

4. Newbie - Creating/Editing XML Values

5. XML, Converting Word doc's to XML files (O'2000)

6. How to create a secure connection, send an xml msg and receive and xml response

7. Render XML+XSL into PrintDocument (not XML) ?

8. XML Newbie question, getting a value from an XML string

9. Parsing XML from an ASP page that Creates XML fails

10. Trying to append a simple XML document as a node in an XML document

11. checking for xml tag/xml data???

12. XML From SQL2000 (Probs with FOR XML EXPLICIT)

 

 
Powered by phpBB® Forum Software