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. Visual Basic
  4. DataSet to XML - Skips if is Null value

DataSet to XML - Skips if is Null value

Scheduled Pinned Locked Moved Visual Basic
questionxml
2 Posts 2 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.
  • P Offline
    P Offline
    Phrone
    wrote on last edited by
    #1

    I try to write down a DataSet to XML. In my dataset I have a row named fe_date (datetime) that sometimes is NULL. When i write the XML file it skips that row if it have a NULL value. How can I force the writer to write the element for fe_date even if it doesn't have a value? I've tried to use myDataSet.WriteXML() and with XmlSerializer() both with the same result.

    D 1 Reply Last reply
    0
    • P Phrone

      I try to write down a DataSet to XML. In my dataset I have a row named fe_date (datetime) that sometimes is NULL. When i write the XML file it skips that row if it have a NULL value. How can I force the writer to write the element for fe_date even if it doesn't have a value? I've tried to use myDataSet.WriteXML() and with XmlSerializer() both with the same result.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      I've never had to do this, but off the top of my head, it would probably require you supply custom serializer code in your object class to support this. Possibly adding an attribute to the tag. This same code would also supply the ability to interpret the XML and convert it back to an object. Take a look at this[^] for the idea. AFAIK, there is no way to tell the standard serializer to output empty tags. NULL is not really defined in XML, so it's no surprise that it won't output an empty tag set.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      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