By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,065 Members | 1,598 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,065 IT Pros & Developers. It's quick & easy.

remove xml file root tag

P: n/a
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 (<Rootand </Root>), can anyone
tell how?

Thanks for your time.

Martin

Nov 9 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
martin1 wrote:
<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 (<Rootand </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.SelectSingl eNode("Root/AutoData"),
Xml_Document.DocumentElement)

Xml_Document.Save("file2.xml")
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 9 '06 #2

P: n/a
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.

"Martin Honnen" wrote:
martin1 wrote:
<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 (<Rootand </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.SelectSingl eNode("Root/AutoData"),
Xml_Document.DocumentElement)

Xml_Document.Save("file2.xml")
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 9 '06 #3

P: n/a
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
martin1 wrote:
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.

"Martin Honnen" wrote:
martin1 wrote:
<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 (<Rootand </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.SelectSingl eNode("Root/AutoData"),
Xml_Document.DocumentElement)

Xml_Document.Save("file2.xml")
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.