473,387 Members | 1,606 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,387 software developers and data experts.

framing XML

HI,
I have a XML document like this,
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
What I wanted to do is, add an root element to this so that it will look like
<sample>
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
<sample>

How do I do this. I am new to this XML stuff. How do I make the sample, the
root node of the colore node?
Nov 19 '05 #1
4 931
We need a little more to go on than that. What are you producing the XML
with?

/Lars

"Venkat" <Ve****@discussions.microsoft.com> skrev i meddelandet
news:EF**********************************@microsof t.com...
HI,
I have a XML document like this,
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
What I wanted to do is, add an root element to this so that it will look
like
<sample>
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
<sample>

How do I do this. I am new to this XML stuff. How do I make the sample,
the
root node of the colore node?

Nov 19 '05 #2
Think the opposite way around. create a new node of <sample></sample>, then
append the existing node structure as a child node of that.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Venkat" <Ve****@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
HI,
I have a XML document like this,
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
What I wanted to do is, add an root element to this so that it will look
like
<sample>
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
<sample>

How do I do this. I am new to this XML stuff. How do I make the sample,
the
root node of the colore node?

Nov 19 '05 #3
I think This will work, is there any other way.

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("d:\\test\\test.xml");
XmlDocument doc1 = new XmlDocument();

XmlElement elem = doc1.CreateElement("Sample"); // XmlElement
elem.InnerXml = xmldoc.InnerXml;
doc1.AppendChild(elem);


"Jason Brown [MSFT]" wrote:
Think the opposite way around. create a new node of <sample></sample>, then
append the existing node structure as a child node of that.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Venkat" <Ve****@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
HI,
I have a XML document like this,
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
What I wanted to do is, add an root element to this so that it will look
like
<sample>
<colore>
<Red>1</Red1>
<blue>2</blue>
<colore>
<sample>

How do I do this. I am new to this XML stuff. How do I make the sample,
the
root node of the colore node?


Nov 19 '05 #4
There's always more than way of doing things, but as you say, that looks
like it should work OK, at first glance anyway - my brain is in a more COM
than .NET mode at the moment so forgive me if I've got crossed-eyes

I'd be tempted to replace elem.InnerXml = xmldoc.InnerXml; with a call to
appendChild() myself, but it more or less covers it. Try it and see.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Venkat" <Ve****@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
I think This will work, is there any other way.

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load("d:\\test\\test.xml");
XmlDocument doc1 = new XmlDocument();

XmlElement elem = doc1.CreateElement("Sample"); // XmlElement
elem.InnerXml = xmldoc.InnerXml;
doc1.AppendChild(elem);


"Jason Brown [MSFT]" wrote:
Think the opposite way around. create a new node of <sample></sample>,
then
append the existing node structure as a child node of that.
--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
"Venkat" <Ve****@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
> HI,
> I have a XML document like this,
> <colore>
> <Red>1</Red1>
> <blue>2</blue>
> <colore>
> What I wanted to do is, add an root element to this so that it will
> look
> like
> <sample>
> <colore>
> <Red>1</Red1>
> <blue>2</blue>
> <colore>
> <sample>
>
> How do I do this. I am new to this XML stuff. How do I make the sample,
> the
> root node of the colore node?


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TJ Bright | last post by:
Hey all, Been working on a site and it's about 98% done now :) I'm having an issue where the site is framed with a about three <frameset>'s. Because of how I wanted it to scroll and where the...
6
by: chris Struhar | last post by:
I have to transmit an icon across the internet from a client to a server which handles connections from many different clients and just continuously loops through receiving data from the buffer....
18
by: Jonathan Carmichael | last post by:
I am building a website for the first time. In attempting to validate my frameset html file I came across the following URL http://www.w3.org/TR/1999/REC-html401-19991224/ The 3 errors I am...
3
by: Shapper | last post by:
Hello, I am working on an ASP.NET/VB web site. I have several links including menu links. Considerer a want to load a page named page.aspx. I can do it using javascript. Or using this code:...
4
by: | last post by:
I have about 20 MsgBox occurance in by program, which I use to inform the user of the progress of the program, or ask confirmation of an action, or simply to act separators to various parts of the...
5
by: murrayatuptowngallery | last post by:
I'm caught in a classic finger-pointing situation. My hosting company's server appears to be automatically inserting JS tags into a JS-free html page that has an image inked to a 2nd page with...
11
by: rfox | last post by:
I've built a site using tables for layout, and it looks ok in everything but in IE where it places extra space around the graphics that contain a rollover script. (Please see...
0
by: EvilProject | last post by:
Hi, i Created a Polygon shaped control using the API Function CreatePolygonRgn, now i want to draw a border to the control. but it appears theres no function that frames a region in the graphics...
23
by: WebFoot | last post by:
Is there a reliable way for a webpage to either break out or refuse to display when a hostile website puts it in a frame? I know about the JavaScript solution, but not all visitors have...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.