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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. how to write xml? [modified]

how to write xml? [modified]

Scheduled Pinned Locked Moved C#
xmlhelptutorialquestionannouncement
3 Posts 3 Posters 1 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.
  • M Offline
    M Offline
    Member 2321293
    wrote on last edited by
    #1

    Hi, Is anyone can tell me how to write a xml file that can return me a result look like this: <?xml version="1.0"?> <Items> <Appointment Start="07/12/2008 11:05:00" End="07/12/2008 14:30:00" .../> <Appointment Start="07/14/2008 08:15:00" End="07/16/2008 16:40:00" .../> </Items> Above is my expected look of my xml file. These data <Appointment start=".... /> are set EXACTLY THE SAME into a dataset and the table name is "xmldata" And before it is generated I try to loop this dataset and hope to generate a xml look like above. but i alway fail to get a correct format. its comes like this: <?xml version="1.0" standalone="yes"?> <Items> <xmldata> <Data>Appointment Start='07/12/2008 11:05:00' End='07/12/2008 14:30:00' Description='Rent this car ' Label='2' Location='city' ResourceId='1' Status='3' Subject='Mr.Brown' </Data> </xmldata> <xmldata> <Data>Appointment Start='07/14/2008 08:15:00' End='07/16/2008 16:40:00' Description='Scheduled repair of this car' Label='4' Location='Service Center' ResourceId='1' Status='2' Subject='Repair' </Data> </xmldata> </Items> XML above by using: ldt_ds.Tables["xmldata"].WriteXml(sourcePath2, false); Hope someone can help on this. Thank you. by CS Tan

    modified on Saturday, November 7, 2009 12:06 PM

    N P 2 Replies Last reply
    0
    • M Member 2321293

      Hi, Is anyone can tell me how to write a xml file that can return me a result look like this: <?xml version="1.0"?> <Items> <Appointment Start="07/12/2008 11:05:00" End="07/12/2008 14:30:00" .../> <Appointment Start="07/14/2008 08:15:00" End="07/16/2008 16:40:00" .../> </Items> Above is my expected look of my xml file. These data <Appointment start=".... /> are set EXACTLY THE SAME into a dataset and the table name is "xmldata" And before it is generated I try to loop this dataset and hope to generate a xml look like above. but i alway fail to get a correct format. its comes like this: <?xml version="1.0" standalone="yes"?> <Items> <xmldata> <Data>Appointment Start='07/12/2008 11:05:00' End='07/12/2008 14:30:00' Description='Rent this car ' Label='2' Location='city' ResourceId='1' Status='3' Subject='Mr.Brown' </Data> </xmldata> <xmldata> <Data>Appointment Start='07/14/2008 08:15:00' End='07/16/2008 16:40:00' Description='Scheduled repair of this car' Label='4' Location='Service Center' ResourceId='1' Status='2' Subject='Repair' </Data> </xmldata> </Items> XML above by using: ldt_ds.Tables["xmldata"].WriteXml(sourcePath2, false); Hope someone can help on this. Thank you. by CS Tan

      modified on Saturday, November 7, 2009 12:06 PM

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You have several options. If you are using SQL Server, you can use the FOR XML clause in the stored proc you are using to query the data. You can use XSLT or Linq to XML to transform the given XML into the desired format. You can use a combination of Linq To XML and Linq to SQL to created the required output.


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • M Member 2321293

        Hi, Is anyone can tell me how to write a xml file that can return me a result look like this: <?xml version="1.0"?> <Items> <Appointment Start="07/12/2008 11:05:00" End="07/12/2008 14:30:00" .../> <Appointment Start="07/14/2008 08:15:00" End="07/16/2008 16:40:00" .../> </Items> Above is my expected look of my xml file. These data <Appointment start=".... /> are set EXACTLY THE SAME into a dataset and the table name is "xmldata" And before it is generated I try to loop this dataset and hope to generate a xml look like above. but i alway fail to get a correct format. its comes like this: <?xml version="1.0" standalone="yes"?> <Items> <xmldata> <Data>Appointment Start='07/12/2008 11:05:00' End='07/12/2008 14:30:00' Description='Rent this car ' Label='2' Location='city' ResourceId='1' Status='3' Subject='Mr.Brown' </Data> </xmldata> <xmldata> <Data>Appointment Start='07/14/2008 08:15:00' End='07/16/2008 16:40:00' Description='Scheduled repair of this car' Label='4' Location='Service Center' ResourceId='1' Status='2' Subject='Repair' </Data> </xmldata> </Items> XML above by using: ldt_ds.Tables["xmldata"].WriteXml(sourcePath2, false); Hope someone can help on this. Thank you. by CS Tan

        modified on Saturday, November 7, 2009 12:06 PM

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

        Never expect an automated tool to produce what you want. I'd use an XmlDocument to do that.

        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