aphillips
asked on
Special characters in attributes
I am reading/writing XML using DOM from C++. Some attributes are a C-like expression that can include &, <, > as well as single- and/or double-quotes.
I have found lots of info on XML attributes that basically says if you want to use a double-quote enclose the attribute in single-quotes and vice-versa. None address the issue of including both double- and single-quotes in the same attribute text.
Also, I assume that I have to converts and ampersand (&) to & when writing the XML, and convert back when reading. Putting an & in the attribute text does not work, although I have never read that it should be a problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
> & becomes &
> ' becomes '
> " becomes "
Thanks, I have never seen ' or " before. I also didn't know you could use & in an attribute string.
> If you're using the DOM, the conversions should be transparent ...
You are right. I was creating the XML by hand for testing. The & was giving errors when reading the attributes but using DOM to create the XML this all becomes transparent.