Empty elements created with an XmlTextWriter

  • Thread starter Thread starter Oenone
  • Start date Start date
O

Oenone

I am using an XmlTextWriter to create an XML document, which we then send to
a client. The document is failing to validate against the DTD we are
providng when the load it into their (non-Microsoft) application, despite it
validating fine in VB.NET.

I believe we may have tracked the issue down to the way their software is
interpreting empty elements. When the element is written like this:

\\\
[...]
<SomeElement />
[...]
///

....the validation fails. However, if we write the element as:

\\\
[...]
<SomeElement></SomeElement>
[...]
///

.... the validation succeeds.

Is there a way of getting the XmlTextWriter to automatically produce "long"
empty elements like in my second example?

Many thanks,
 
Oenone said:
I am using an XmlTextWriter to create an XML document, which we then send
to a client. The document is failing to validate against the DTD we are
providng when the load it into their (non-Microsoft) application, despite
it validating fine in VB.NET.
[...]
\\\
[...]
<SomeElement />
[...]
///

...the validation fails. However, if we write the element as:

\\\
[...]
<SomeElement></SomeElement>
[...]
///

... the validation succeeds.

Is there a way of getting the XmlTextWriter to automatically produce
"long" empty elements like in my second example?

You may want to use the 'XmlTextWriter''s 'WriteFullEndElement' method to
prevent it from emitting a short end tag.
 
Herfried said:
You may want to use the 'XmlTextWriter''s 'WriteFullEndElement'
method to prevent it from emitting a short end tag.

Perfect -- as usual, thanks very much for your assistance.
 
Back
Top