views:

82

answers:

1

I am using Xerces library, everything is fine to use but now I want to escape the XML string and I found there is a XMLFormatter class used for that, after I dig into the doc, I see it is really hard to use from the constructor perspective. What I want is just 2 functions:

string escape(string);

string unescape(string);

why xerces makes this so hard to do?

A: 

What you're trying to do isn't really related to the XML itself. If you were to store the XML to a file then this wouldn't be necessary. Ditto if you were sending over a network connection using just TPC or UDP. I assume you want to send it over HTTP, and this is really something I would expect to see as a function of whatever library you're using to do your HTTP communication. Do you expect to see functions to escape for MySQL, MS SQL, Oracle, JSON?

tloach
No, that's not true, what if the attribute has ' inside? That will mess up the parser, eg) <cmd attri='ab'/> <cmd attri='a'b' />
Bin Chen