framing XML

Discussion in 'ASP .Net' started by =?Utf-8?B?VmVua2F0?=, Jan 19, 2005.

  1. 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?
    =?Utf-8?B?VmVua2F0?=, Jan 19, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?VmVua2F0?=

    Lars Netzel Guest

    We need a little more to go on than that. What are you producing the XML
    with?

    /Lars



    "Venkat" <> skrev i meddelandet
    news:...
    > 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?
    Lars Netzel, Jan 19, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > 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?
    Jason Brown [MSFT], Jan 19, 2005
    #3
  4. 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" <> wrote in message
    > news:...
    > > 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?

    >
    >
    >
    =?Utf-8?B?VmVua2F0?=, Jan 19, 2005
    #4
  5. 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" <> wrote in message
    news:D...
    >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" <> wrote in message
    >> news:...
    >> > 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?

    >>
    >>
    >>
    Jason Brown [MSFT], Jan 19, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    14
    Views:
    867
  2. David Russell

    Assistance on "framing" a section

    David Russell, Jul 3, 2005, in forum: HTML
    Replies:
    1
    Views:
    307
    Beauregard T. Shagnasty
    Jul 3, 2005
  3. David Russell

    Re: Assistance on "framing" a section

    David Russell, Jul 3, 2005, in forum: HTML
    Replies:
    2
    Views:
    326
    Travis Newbury
    Jul 4, 2005
  4. MS

    Quicktime framing video

    MS, Sep 6, 2007, in forum: HTML
    Replies:
    10
    Views:
    598
  5. RVic

    TCP Framing

    RVic, Sep 9, 2009, in forum: Java
    Replies:
    1
    Views:
    377
    Arne Vajhøj
    Sep 9, 2009
Loading...

Share This Page