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. Formating the xml-output from a DataSet

Formating the xml-output from a DataSet

Scheduled Pinned Locked Moved C#
questionxml
4 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.
  • K Offline
    K Offline
    Knappen
    wrote on last edited by
    #1

    Helo :~ I know that I have done this before, controling how the output-xml is formated. The default i:

    <NewDataSet>
    <table>
    <col1>val</col1>
    <col2>val</col2>
    </table>
    <table>
    <col1>val</col1>
    <col2>val</col2>
    </table>
    <NewDataSet>

    But I want it to be:

    <NewDataSet>
    <table col1="val" col2="val">
    <table col1="val" col2="val">
    </NewDataSet>

    What is the property to set ????

    L B 2 Replies Last reply
    0
    • K Knappen

      Helo :~ I know that I have done this before, controling how the output-xml is formated. The default i:

      <NewDataSet>
      <table>
      <col1>val</col1>
      <col2>val</col2>
      </table>
      <table>
      <col1>val</col1>
      <col2>val</col2>
      </table>
      <NewDataSet>

      But I want it to be:

      <NewDataSet>
      <table col1="val" col2="val">
      <table col1="val" col2="val">
      </NewDataSet>

      What is the property to set ????

      L Offline
      L Offline
      Le centriste
      wrote on last edited by
      #2

      Do you have a schema? You need one to achieve this. In VS, open the .xsd file,and click on DataSet tab at the bottom. You will see a table named table (as your example) and the columns with their types. You will see in the first column an E, change it to an A and there you go. If you don't have a schema, simply build by hand a XML file that will look like what you want. Open it with VS and choose, from the XML menu, Create Schema. In your program, before loading the DataSet with data from an XML file, or before saving to an XML file, use one of the myDataSet.ReadXmlSchema methods. When reading, always use the XmlReadMode.Auto and maybe set the myDataSet.EnforceConstraints property to true to detect any schema errors. Have fun!

      1 Reply Last reply
      0
      • K Knappen

        Helo :~ I know that I have done this before, controling how the output-xml is formated. The default i:

        <NewDataSet>
        <table>
        <col1>val</col1>
        <col2>val</col2>
        </table>
        <table>
        <col1>val</col1>
        <col2>val</col2>
        </table>
        <NewDataSet>

        But I want it to be:

        <NewDataSet>
        <table col1="val" col2="val">
        <table col1="val" col2="val">
        </NewDataSet>

        What is the property to set ????

        B Offline
        B Offline
        Bruce Duncan
        wrote on last edited by
        #3

        You can set the ColumnMapping property on each column to MappingType.Attribute.

        Without nipples, breasts would be pointless.

        K 1 Reply Last reply
        0
        • B Bruce Duncan

          You can set the ColumnMapping property on each column to MappingType.Attribute.

          Without nipples, breasts would be pointless.

          K Offline
          K Offline
          Knappen
          wrote on last edited by
          #4

          :-DGreat! That was the best and eazyest solution. To solve it with XMLSchema created alot of overhead and puluted the xml with alot of xmlns-information...

          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