Click to See Complete Forum and Search --> : More XmlDocument Help, save options?


code?
December 30th, 2008, 04:12 AM
Okay, so when I save a document with a blank attribute like this.

<Attrib></Attrib>

It comes out looking like this.

<Attrib>
</Attrib>

Is there any way to prevent this?

dannystommen
December 30th, 2008, 04:15 AM
I don't know if there is anyway to prevent it, but if the element is empty you could also use

<Attrib/>

code?
December 30th, 2008, 04:19 AM
That's a negative, it won't work that way for the situation I'm in.

code?
January 3rd, 2009, 08:47 PM
Nothing? Are you serious?

TheCPUWizard
January 3rd, 2009, 09:25 PM
That's a negative, it won't work that way for the situation I'm in.

First, that is an element, NOT an attribute.

Second, if your code does not work with all variations equally well, then you are not standards compliant.

With increasing processing happening to XML content at varying levels, we are seeing more and more variations in format. Providing data contains (or references) a valid schema, and conforms to that schema, NOTHING else should matter.

There are a number of "fuzzing" tools available (they make psuedo random changes to your data that do NOT impact the schema) to help test this aspect.

code?
January 3rd, 2009, 09:48 PM
Well, I seem to have found a solution. I set PreserveWhitespace to true (or false) and it made the document all one line.

It turns out, that the other program that reads the Xml, the file doesn't need to be fancy.