Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make XMLDocument do not put spaces on self-closed tags?

I have an XML well formatted without any spaces. It' must be like that.

When I load it to XMLDocument to sign, the self-closing tags gets an extra white space and

    <cEAN/>

becomes:

     <cEAN />

Once this document must be signed, it's impossible to remove the white space.

The property PreserveWhiteSpace doesn't made any difference to the result.

How can I change this behavior?

like image 998
João Vieira Avatar asked Feb 03 '11 00:02

João Vieira


People also ask

Does XML allow self-closing tags?

All tags in XML or XHTML can be used as self-closing by closing them with (<.. />). HTML5: Using a slash is absolutely optional. HTML4: Using a slash is technically invalid. However, the W3C's HTML validator still accepts it.

What is a self-closing tag in XML?

A self-closing tag is an element of HTML code that has evolved in the language. Typically, the self-closing tag makes use of a “/” character in order to effectively close out a beginning tag enclosed in sideways carets.

How do you close an XML attribute?

The end tag functions exactly like a right parenthesis or a closing quotation mark or a right curly brace. It contains no data of its own; it simply ends the most recent (innermost) tag with the same name. XML requires a matching end tag for each start tag.


1 Answers

There is no space before the closing "/" in the XmlDocument. XmlDocument is a data structure consisting of nodes. It is binary. It is not text.

Any extra space you are seeing exists only when you serialize the document as text.

Are you actually having a problem with signing, or do you only think you will have such a problem?

like image 142
John Saunders Avatar answered Sep 26 '22 19:09

John Saunders