473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

remove xml file root tag

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
3 5793
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Juliano Freitas | last post by:
Hello!! how can i remove a child in DOM ? for example, i have thi xml below: <root> <user> <name> juliano </name> </user>
1
by: LoF | last post by:
Hi, I am generating deeply nested XML document from a Dataset using ' Write to the file with the WriteXml method. DataSet21.WriteXml(myXmlWriter) The generated XML contains the <DataSet2>...
6
by: Nikhil Patel | last post by:
Hi all, Following is a portion of an XML document. I need to remove all nodes that belong to ns0 without deleting their child nodes. So in the following example , I want to delete "ns0:Proposal"...
2
by: Simon-Pierre Jarry | last post by:
Hi, I created a custom HttpModule for managing the security of my application. in "Init" sub, I regsiter the events doing that : Public Sub Init(ByVal context As System.Web.HttpApplication)...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
6
by: fzhang | last post by:
I am relatively new to XML and C#. So, forgive me if this question is too newbie. :-) While assuming this is an easy programming task, I couldn't find a single reference anywhere for how to do...
1
by: Que | last post by:
hi i have the following xml document <root> <item> <key> <scode></scode> </key> <scode></scode> <desc></desc> <pc></pc>
3
by: dazzle | last post by:
I have an XML file and I would like to remove duplicate nodes within it but I can't get my head round on how to do this. Example XML file: <root> <plugin> <title>A9</title> <url>some...
1
by: Samuel R. Neff | last post by:
We have a problem with Web.config inheritance in two of our applications. We have an old app which is poorly written and must be in the root of the server. We have a newer app which runs from a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.