Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Write XML Dynamically according to tree structure in windows c#

Write XML Dynamically according to tree structure in windows c#

Scheduled Pinned Locked Moved C#
csharpdata-structuresxml
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rummer
    wrote on last edited by
    #1

    Hi All, I have an "Acount" and my Acount has multiple "users" . And my user have three settings like App,Web,Key So we have to write XML on this behalf of tree. Structure like - Acount User1 Acount Setting web App Key User2 Acount Setting web App Key I have create XML like same as structure.

    M P 2 Replies Last reply
    0
    • R rummer

      Hi All, I have an "Acount" and my Acount has multiple "users" . And my user have three settings like App,Web,Key So we have to write XML on this behalf of tree. Structure like - Acount User1 Acount Setting web App Key User2 Acount Setting web App Key I have create XML like same as structure.

      M Offline
      M Offline
      markovl
      wrote on last edited by
      #2

      Have a look at the XmlDocument class here[^]. Basically you'd create a XmlDocument object and add XmlElement [^] instances. For example:

      XmlDocument document = new XmlDocument();

      // Create the root Account element.
      XmlElement root = document.CreateElement("Account");
      // Add attributes to the element
      root.SetAttribute("SomeAttribute", "42");
      // Add the element to the document's tree.
      document.AppendChild(root);

      // Create the child elements
      XmlElement child = document.CreateElement("User1");
      // Add the child to the root element
      root.AppendChild(child);

      // Create a grandchild
      XmlELement grandchild = document.CreateElement("AccountSetting");
      child.AppendChild(grandchild);

      //etc, etc...

      //Finally you could save the document to file:
      document.Save(pathToMyXmlFile);

      2A

      1 Reply Last reply
      0
      • R rummer

        Hi All, I have an "Acount" and my Acount has multiple "users" . And my user have three settings like App,Web,Key So we have to write XML on this behalf of tree. Structure like - Acount User1 Acount Setting web App Key User2 Acount Setting web App Key I have create XML like same as structure.

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Markovl's suggestion is good and I use it for small amounts of data. For large amounts of data I tend to use an XmlWriter -- I keep thinking of writing something about it.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups