Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am working on vb.net Window application.

here i have a xml file

<archivedata>

  <archive>
    <date>1-1-1980</date>
    <name>Archive Name</name>
    <email>someemail@domain.com</email>
    <time>11:40</time>
  </archive>

</archivedata>


i need to append pragmatically like..
<archivedata>

  <archive>
    <date>1-1-1980</date>
    <name>Archive Name</name>
    <email>someemail@domain.com</email>
    <time>11:40</time>
  </archive>

  <archive>
    <date>1-1-1990</date>
    <name>Archive Name</name>
    <email>someemail@domain.com</email>
    <time>09:40</time>
  </archive>
	
  <archive>
    <date>1-1-1999</date>
    <name>Archive Name</name>
    <email>someemail@domain.com</email>
    <time>10:40</time>
  </archive>
   
  .
  .
  .
  and so on...

</archivedata>


can somebody help me?

thanks
Posted

Here[^] is an example that does this using XMLDocument.
 
Share this answer
 
Try This:

VB
Dim newArchive As String = _
            "<archive>" & _
            "    <date>1-1-1993</date>" & _
            "    <name>bill</name>" & _
            "    <email>billmail@yahoo.com</email>" & _
            "    <time>1:39</time>" & _
            "  </archive>"
        Dim xmldoc1 As New XmlDocument()
        xmldoc1.Load("test.xml")
        Dim xmldocFragment As XmlDocumentFragment = xmldoc1.CreateDocumentFragment()
        xmldocFragment.InnerXml = newArchive
        Dim XmlNode1 As XmlNode = xmldoc1.DocumentElement
        XmlNode1.AppendChild(xmldocFragment)
        xmldoc1.Save("test.xml")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900