Take info from textbox and write to xml

Would just like a code example of taking the info from a textbox and writing it to xml.

I want to add new info to the xml each time, not overwriting the old info. 

0
headmax
5/4/2009 9:32:17 PM
asp.net.xml-datasource 7181 articles. 0 followers. Follow

2 Replies
346 Views

Similar Articles

[PageSpeed] 14

here is a sniped of a function that could help.

Private Function addEdition(ByVal editionName As String, ByVal editionyear As String, ByVal editionmonth As String, ByVal editionday As String) As Integer

loNode = loXMLDoc.SelectSingleNode("Tree/Node/Node[@Text='" + editionName + "']/Node[@Text='" + editionyear + "']/Node[@Text='" + editionmonth + "']/Node[@Text='" + editionmonth + " " + editionday + "']")

If loNode Is Nothing Then ' the day dose mot yes exist

Dim fileSystemeditionName As String = Replace(editionName, " ", "")

Dim EditionText As String = editionmonth + " " + editionday

Dim EditionValue As String = fileSystemeditionName + "/" + editionyear + "/" + editionmonth + "/" + editionday + editionmonth + editionyear

Dim newEdition As XmlElement = loXMLDoc.CreateElement("Node")

newEdition.SetAttribute("Text", EditionText)

newEdition.SetAttribute("value", EditionValue)

newEdition.SetAttribute("expand", "false")loNode = loXMLDoc.SelectSingleNode("Tree/Node/Node[@Text='" + editionName + "']/Node[@Text='" + editionyear + "']/Node[@Text='" + editionmonth + "']")

loNode.InsertBefore(newEdition, loNode.FirstChild)

loXMLDoc.Save(Server.MapPath("Xtree.xml"))

End If

End Function


Liam Mcmullen
1
liammcmullen
5/4/2009 9:42:42 PM
Try this (using AppendChild function):

  

 
        ' VB.NET
        Dim xmldoc As XmlDocument = New XmlDocument()
        xmldoc.Load(Server.MapPath("App_Data\Test.xml"))

        Dim newelement As XmlElement = xmldoc.CreateElement("testitem")
        Dim xmlDate As XmlElement = xmldoc.CreateElement("date")
        Dim xmlName As XmlElement = xmldoc.CreateElement("name")

        xmlDate.InnerText = DateTime.Now.ToLongDateString & " " & DateTime.Now.ToLongTimeString
        xmlName.InnerText = Me.txtName.Text.Trim()

        newelement.AppendChild(xmlDate)
        newelement.AppendChild(xmlName)

        xmldoc.DocumentElement.AppendChild(newelement)
        xmldoc.Save(Server.MapPath("App_Data\Test.xml"))
 

 

 

    // C# .NET
    XmlDocument xmldoc = new XmlDocument();
    xmldoc.Load(Server.MapPath("App_Data\\Test.xml"));
    
    XmlElement newelement = xmldoc.CreateElement("testitem");
    XmlElement xmlDate = xmldoc.CreateElement("date");
    XmlElement xmlName = xmldoc.CreateElement("name");
    
    xmlDate.InnerText = DateTime.Now.ToLongDateString + " " + DateTime.Now.ToLongTimeString;
    xmlName.InnerText = this.txtName.Text.Trim();
    
    newelement.AppendChild(xmlDate);
    newelement.AppendChild(xmlName);
    
    xmldoc.DocumentElement.AppendChild(newelement);
    xmldoc.Save(Server.MapPath("App_Data\\Test.xml"));
  
When you ask a question, remember to click "Mark As Answer" when you get a reply which answers your question.
0
Kulrom
5/4/2009 9:49:23 PM
Reply:

Similar Artilces:

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

superreview cancelled: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178081] (Av1a) <textbox.xml> (nit + anonid)
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178081: (Av1a) <textbox.xml> (nit + anonid) https://bugzilla.mozilla.org/attachment.cgi?id=178081&action=edit ...

superreview requested: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178157] (Av1b) <textbox.xml> (full sync ++)
Serge GAUTHERIE <gautheri@noos.fr> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178157: (Av1b) <textbox.xml> (full sync ++) https://bugzilla.mozilla.org/attachment.cgi?id=178157&action=edit ...

superreview granted: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178157] (Av1b) <textbox.xml> (full sync ++)
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has granted Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178157: (Av1b) <textbox.xml> (full sync ++) https://bugzilla.mozilla.org/attachment.cgi?id=178157&action=edit ...

superreview requested: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178081] (Av1a) <textbox.xml> (nit + anonid)
Serge GAUTHERIE <gautheri@noos.fr> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178081: (Av1a) <textbox.xml> (nit + anonid) https://bugzilla.mozilla.org/attachment.cgi?id=178081&action=edit ...

superreview requested: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178036] (Av1-MAS) <textbox.xml> (nit fix)
Serge GAUTHERIE <gautheri@noos.fr> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178036: (Av1-MAS) <textbox.xml> (nit fix) https://bugzilla.mozilla.org/attachment.cgi?id=178036&action=edit ------- Additional Comments from Serge GAUTHERIE <gautheri@noos.fr> Clears the way to better see the 2 remaining sync to do. Could you (super-)review/check in this patch ? Thanks. Then, would you have time...

superreview cancelled: [Bug 282187] sync xpfe textbox.xml with toolkit textbox.xml : [Attachment 178036] (Av1-MAS) <textbox.xml> (nit fix)
Serge GAUTHERIE <gautheri@noos.fr> has cancelled Serge GAUTHERIE <gautheri@noos.fr>'s request for superreview: Bug 282187: sync xpfe textbox.xml with toolkit textbox.xml https://bugzilla.mozilla.org/show_bug.cgi?id=282187 Attachment 178036: (Av1-MAS) <textbox.xml> (nit fix) https://bugzilla.mozilla.org/attachment.cgi?id=178036&action=edit ...

XMl to XML
Hello,   I retrieved an XML from the dataset which retrieves data from the table in the database. I need to present the data  in a different structure. Is XSLT the way or are there any other options. please let me know. Thanks!! Yes XSLT is a good choice to convert xml file to other forms. You can take a look at XSLT Tutorial.Sincerely,Young Fang...

XML in, XML out
Hi All (and a happy holiday to those that will get a break), I am trying to read in an XML file of addresses. I need to remove all the address data from the file where code =~ /^000/ (there are none in the example data below). I need to reproduce that data 'as is', so I need to honour the tag structure, although the order of the tags doesn't need to be honoured. I have been trying to use XML::Simple and I had a go with XML::Smart but I haven't been able to get the results I want. My best effort is below (with XML::Simple). There are a couple of differences ...

Writing XML from XML policy
Hi All I have a need to write XML policy to write DirXML-EntitlementRef attribute... Attribute is structured and path.xml contains xml document. I have problem to write XML documents TAGs <ref>, <param>, <ref>, </param>, start character < ... I get as result to edir attribute &ltref> while it should be <ref> I have tried to put < &lt; &amp;lt; &#60; &amp;#60; xpath(string('&lt;') I cannot find correct way to present < on XML policy Can anyone help me on this one.. V-M Build the requi...

write to a xml with a xml schema
Hi, I have a xml schema, and a xml that validate this schema.I want to append new nodes to this xml with code (c#)which is the best form to do this?thanks...

How do I write XML into an attr, as XML?
I need to write to DirXML-EntitlmentRef, and for the path.xml component I need to write XML. But whenever I try to put something there, the open angle bracket (<) gets escaped to: <add-attr attr-name="DirXML-EntitlementRef"> <value type="structured"> <component name="nameSpace">1</component> <component name="volume">SomeDriverDN</component> <component name="path">&lt;ref/></component> </value> </add-...

How to write a xml file to another computer using path like this \\Server5\XML\XMLTest.xml?
Hi Guys,How can I write a xml file that read from a dataset to another computer in our network?something like this path "\\Server5\XML\XMLTest.xml"I am using below code to write xml file.----------------------------------------            // create a file name to write to.            string filename = "\\Server5\XML\XMLTest.xml";            // create the FileStream to write with.        &nb...

Writing to XML using XML::Writer
Hi, Can anybody give me a simple code snippet which writes or modifies this xml ? =09 <my_list> <guy name=3D"SomeGuy"> <user>Tom</user> <date-of-birth>Aug 2006</date-of-birth> </guy> <guy name=3D"AnotherGuy"> <user>Dicken</user> <date-of-birth>Aug 2006</date-of-birth> =20 </guy> </my_list>=09 I want to read and write into this simple xml, basically changing the values or deleting them. After scanning...

Web resources about - Take info from textbox and write to xml - asp.net.xml-datasource

Aqua (user interface) - Wikipedia, the free encyclopedia
Aqua is the GUI and primary visual theme of Apple Inc. 's OS X operating system . It is based around the theme of water, as its name suggests, ...

Wikipedia:Sockpuppet investigations - Wikipedia, the free encyclopedia
WP:RFCU redirects here. You may be looking for Wikipedia:Requests for comment/User conduct ( WP:RFC/U ), CheckUser policy ( Wikipedia:CheckUser ...

Help - Identi.ca
Identi.ca is a social service . Users can post short(140 character) status messages which are broadcast totheir friends and colleagues on the ...

City of Whitehorse, YT : Contact
Employment - Bylaws - Document Library - FAQ - Contact Us Search Query Textbox Home Home About Whitehorse Notify Me Contact Us Employee Links ...

www.asianewsphoto.com Help
Help for uploading pictures Noun explanation Group pictures: a basic unit which stands for a piece of news photo in system; include: information ...

Metamorphose: All-In-One File/Folder Renamer For Windows, Mac & Linux
Previously, we’ve reviewed many batch file-renaming applications like ReNamer (read review), NameChanger (read review), File Grinder (read review) ...

How to build a Twitter extension for Chrome
Ars takes a close look at the Chrome Web browser's new extension system. In …

ASUSTeK Computer Inc. -Support- RSS
... RSS Service, please follow the instructions below. STEP 1. Select the product to subscribe. STEP 2. The RSS link will be shown on the Textbox ...

authonomy writers and readers - Daniel Escurel Occeno's profile - authonomy writing community
... of the Point Guard”. It is entered in www.textnovel.com writing contest.In the TEXTNOVEL website simply type in “Lee Chon” in the textbox search ...

Baseball Prospectus
Forgot Your Password? Enter your username in the textbox below. Username: If you don't remember your username, please contact Customer Service ...

Resources last updated: 12/17/2015 10:23:14 AM