I have an XML element that has a url as one of its children, for example:http://maps.google.com/FortWorth&Texas,more+url;data
When analyzing this question, I have two problems:1.) The character ( & ) breaks the entire syntax, if not replaced, and amp (which violates the URL)2.) The comma ( , ) tries to send my parser to the next child, which will lead to incomplete Url.
What can I do to fix this?I am using Javascript and PHP.
Replacing &with &should not violate the URL. You did not specify :?
&
&
The best solution is you should wrap this in a CDATA tag:
<![CDATA[ http://maps.google.com/FortWorth&Texas,more+url;data ]]>
Which tells the XML parser to treat it as text, rather than parse &.
There are certain characters in XML that are not allowed - you need to βescapeβ them in the XML document.
These characters and their "escaped" versions:
> > < < & & ' ' " "