Question XML loading problem

dmarvp

New member
Joined
Oct 29, 2010
Messages
3
Programming Experience
3-5
Hi everyone, I have a little problem with the class XmlDocument in .net. I'm using framework 2.0 and I am loading an xmlDocument from a path. The xml has a node without value, defined exactly like this:

<somexmlnode/>

When I load the xml using the xmlDocument class, it seems that it is internally modified to read this as:

<somexmlnode_/>

where "_" is a white space. I can see this when I inspect the InnerXml property of my xmlDocument class. Does somebody know how to prevent this from happening ? :confused:

It is very important to me to read all xml's EXACTLY as they are without suffering any kind of change. Any help or ideas would be greatly appreciated :)
 
There is semantically no difference between the two, so I think you need to elaborate on this.
 
I know, the problem is that this xml is digitally signed. And to verify the signature I need to read it without any kind of alteration. :eek:
 
I don't understand how that is related to XmlDocument class, surely it must be the text/bytes that is verified? In that case do that prior to loading the data into XmlDocument.
 
My xml is generated once. Then signed. The results of that signature are attached as as base64 string to a node in the same xml. To verify my xml I have to load it, remove the extra nodes from the signature, then verify the contents of those extra nodes with the "original" xml. Not as bytes, but as a String. This is why it's so important that the xml once loaded should not be alterated (not extra white spaces, not special characters).

It's been working great for over a year until we recently received some xml's with some empty nodes. The xmlDocument class is changing them when they are loaded, and as a result they can't be verified. We don't have control over the xml's that we receive, this is kind of an inter-organization thing we have (we must respect the structure, but every organization uses different ways to create their xml's and they even use different encodings sometimes), but we have to be able to verify them all.
 
I think you're out of luck on that, you have based the verification upon the data being plain text content and not really a xml structure. The XmlDocument actually has a PreserveWhitespace property, which preserves insignificant whitespace between nodes (because these may be considered exact text nodes), but it has no effect on empty nodes inner termination.
 
Back
Top