remove xml file root tag

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, All,

the xml file is like this:

<Root>
<AutoData>
<Table1>
<Data1> 10 </Data1>
<Data2> 20 </Data2>
<Data3> 40 </Data3>
<Table1>
<Table2>
<Data1> 10 </Data1>
<Data2> 20 </Data2>
<Data3> 40 </Data3>
<Table2>
</AutoData>
</Root>

I want to remove Root open and close tag (<Root> and </Root>), can anyone
tell how?

Thanks for your time.

Martin
 
martin1 said:
<Root>
<AutoData>
<Table1>
<Data1> 10 </Data1>
<Data2> 20 </Data2>
<Data3> 40 </Data3>
<Table1>
<Table2>
<Data1> 10 </Data1>
<Data2> 20 </Data2>
<Data3> 40 </Data3>
<Table2>
</AutoData>
</Root>

I want to remove Root open and close tag (<Root> and </Root>), can anyone
tell how?


With the above structure it is easy, simply replace the DocumentElement
with the AutoData element:

Dim Xml_Document as System.Xml.XmlDocument = New System.Xml.XmlDocument()

Xml_Document.Load("file.xml")

Xml_Document.ReplaceChild(Xml_Document.SelectSingleNode("Root/AutoData"),
Xml_Document.DocumentElement)

Xml_Document.Save("file2.xml")
 
Thank you for yuor quick response! Martin

I will post 3 more xml questions in couple of minutes later, can you take a
look at it?

Thanks for your time.
 
Perhaps you should find an online tuturial, search these newsgroups, or
even visit a library or bookstore and do a little research yourself?

I not trying to be mean here, but when people see you posting 5
questions within two hours, they are very likely to ignore your posts
completely. All I'm asking is for you to please make an effort to find
the answers before you post to a newsgroup. You will learn much more
this way!

Thanks,

Seth Rowe
 
Back
Top