0

I am using XMLWriter to create an XML output of my MySQL Database, and I would like to know how I could prevent this happening <hello></hello> by doing this <hello>nil</hello>

So basically replace "" with "nil".

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
max_
  • 24,076
  • 39
  • 122
  • 211

1 Answers1

0

<hello></hello> is proper for indicating an empty node in XML; the other way is <hello />. Replacing with nil means it's no longer an empty node; it's a node with the text content nil.

If you do that replacement, you're changing the meaning of the data in the XML. This is a terrible idea.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • ok, but not all of the nodes are empty for e.g . It may be a terrible idea, but it would be a lot easier for me! – max_ Mar 14 '11 at 01:19
  • If you replace empty nodes with the text 'nil', how do you know for sure they're empty and that someone didn't save 'nil' in that column? The text 'nil' is NOT the same as a NULL column (which you're encountering). Just because it's easier doesn't mean you should do it; it's lousy design, and anyone who has to come in and work on your code later will really hate it. – Ken White Mar 14 '11 at 01:39
  • I actually work alone, and no one will be adding to this database. I am only using it to read data from. – max_ Mar 14 '11 at 01:44