Loading Xml from a file or a string encodes single quotes

205 views Asked by At

Currently I have a problem with loading xml strings (also tested with loading files) in chilkat. The problem is loadings xml string which have single quotes in some attributes. Chilkat automatically HTML encodes them.

For example when I load the following string:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <ds:Reference URI="#xpointer(//*[@authenticate='true'])" />
</root>

Chilkat returns this, when use .GetXml():

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <ds:Reference URI="#xpointer(//*[@authenticate=&apos;true&apos;])" />
</root>

So when I have to compare digest values, they don't match anymore.

I could make a workaround which just replaces those values, but I'm not happy with that. Maybe there are more encodings of attributes or other values, which could make more trouble.

Do someone know if this is on purpose and why, or maybe just a bug. Are there properties which I have to set and I didn't found?

Thanks

1

There are 1 answers

0
Chilkat Software On

That's the intended behavior. (It's both an HTML entity and an XML special char. See http://xml.silmaril.ie/specials.html) It's not technically incorrect, but I can understand why one behavior might be desired over another.

In any case, if you're hashing XML and comparing with an original, you really don't want to load the XML and re-emit from a DOM style parser. Whitespace, indentation, and other XML special chars could be different. If you really want to compare hashes, you need the XML to be exact -- and that would mean canonicalization. You could use Chilkat to canonicalize the XML. For example, copy the XML into this online tool to generate both the canonicalized XML as well as the code to do the canonicalization.