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. XML / XSL
  4. writing XML in C#.net

writing XML in C#.net

Scheduled Pinned Locked Moved XML / XSL
csharpcomalgorithmsxml
1 Posts 1 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.
  • A Offline
    A Offline
    anumadhu
    wrote on last edited by
    #1

    hello, I am new to both the xml and C#.net technologies. I am generating a xml file in c#.net.I am trying to generate a xml file whose first/root node should look like this: I am using the xmlWriter class to generate the xml. The data for xml is taken from the structure which is filled by the program itself. My code is as follows: private void generateXml() { TreeNode tempNode,selectedNode; frmFindByProgram.stProgram stTemp = new frmFindByProgram.stProgram(); selectedNode=new TreeNode(); tempNode = new TreeNode(); XmlTextWriter writer = new XmlTextWriter("E:\\Projects\\Project1\\July\\26\\ScheduleDemo\\NewXML.xml", new System.Text.UTF8Encoding()); //Write the header information writer.WriteStartDocument(); //Write the root node writer.WriteStartElement("tns", "schedule","http://www.sample.com/Schedule"); //use the record structure int i = 0, count; count = xmlSlotNodes.Count; // sort the slots according to there callSign xmlSlotNodes.Sort(0,count,new Sorting ()); string[] prgmTime = new string[2]; stTemp = (frmFindByProgram.stProgram)xmlSlotNodes[i]; selectedNode=getClickedNode(); writer.Formatting = Formatting.Indented; writer.WriteStartElement("CruiseLine"); // writer.WriteAttributeString("Id", selectedNode.Text ); writer.WriteAttributeString ("Name",selectedNode.Parent.Text); writer.WriteStartElement("Ship"); writer.WriteAttributeString("Name", selectedNode.Text ); writer.WriteStartElement("Channel"); writer.WriteStartElement("CallSign"); writer.WriteAttributeString("Value", stTemp.CallSign); prgmTime = stTemp.Duration.Split('-'); do { stTemp = (frmFindByProgram.stProgram)xmlSlotNodes[i]; pr

    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