Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 5 of 5

Thread: appending xml document

  1. #1

    appending xml document

    I want to append the existing XML document with some tags, I wrote the code but its not working . Can you please suggest me to do this.

    string txt = textBox1.Text.ToString();
    XmlDocument xdoc = newXmlDocument();
    xdoc.LoadXml(txt);
    XmlNode root = xdoc.DocumentElement;
    XmlElement elem = xdoc.CreateElement("price","");
    elem.InnerText =
    "19.95";
    root.InsertAfter(elem, root.FirstChild);
    xdoc.Save(txt);

    Thanks a lot,
    Anjali

  2. #2
    Can you post a snippet of what your XML document looks like? Also, what is not working?

    I changed xdoc.XmlLoad to xdoc.Load, and when I ran it on a sample XML file, the price was displayed at the bottom.

    Thanks,
    Kirupa

    Great, now even Kirupa is { facebooking | twittering }

  3. #3

    More Info

    Ya, its appending.
    But my requirment is to create root element as well as childnodes.
    ex: i have the xml file las follows,

    <?xml version="1.0" encoding="utf-8" ?>
    <plugin xmlns=" ">
    <Book name="HerbertShield">
    <Book name="JavaBook">
    <Book name="CBook">
    <Books name="LetUsC">YeshwantKanitkar</Books>
    <Books name="CBasics">Kottur</Books>
    </Book>
    </Books>
    </plugin>

    This is just an sample xml file. I need to create tags for "CBook" element.
    Can you please suggest me to do this.

    Thanks a lot,
    Anjali

    Quote Originally Posted by kirupa View Post
    Can you post a snippet of what your XML document looks like? Also, what is not working?

    I changed xdoc.XmlLoad to xdoc.Load, and when I ran it on a sample XML file, the price was displayed at the bottom.

    Thanks,
    Kirupa

  4. #4
    That is similar to what I am explaining here where I add a Book node, an attribute, and child nodes: http://www.kirupa.com/net/writingXML_pg2.htm

    Have you had a chance to look through that?

    Thanks,
    Kirupa

    Great, now even Kirupa is { facebooking | twittering }

  5. #5

    Done

    Hmm..Thanks Kiripa...
    Its done...

    Thanks a lot,
    Anjali ....

    Quote Originally Posted by kirupa View Post
    That is similar to what I am explaining here where I add a Book node, an attribute, and child nodes: http://www.kirupa.com/net/writingXML_pg2.htm

    Have you had a chance to look through that?

    Thanks,
    Kirupa

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012