XML Data Problem
benr_mc at cogapp.com
Thu Oct 23 08:24:40 CDT 2008
> The following in a string of XML data causes revCreateXMLTree() to
> return an error:
> <a:Description>Gorillaz & Killers</a:Description>
> Is there a way to handle this?
revCreateXMLTree is correct to return an error; "&" is an illegal character in
XML. (One of two, the other is "<".)
The 'right' way to handle this is for the XML to be valid; which would be done
by either wrapping the offending text in a CDATA section:
<a:Description><![CDATA[Gorillaz & Killers]]></a:Description>
or by using entities in place of the offending characters:
<a:Description>Gorillaz & Killers</a:Description>
However, if you don't have control over the XML, and want to parse it anyway,
you could try using the dontparseBadData parameter to revCreateXMLTree, to
encourage it to do its best. That will probably, but not definitely, let you
get away with it - at least for that example.
Failing that, if you can't get valid XML, and it's so invalid that
revCreateXMLTree won't accept it even when asked to be more tolerant, and you
want to parse it anyway, you might have to do some preprocessing to massage
out known errors that you want to overlook.
More information about the use-livecode