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?