I am trying to parse xml-ku (XML-version of the directory page) as follows:

$xml_string = file_get_contents($URL); $xml = simplexml_load_string($xml_string); 

The simplexml_load_string () function generated an error after one of the pages in the picture name got the & symbol (for example, blabla & blabla.png). How to get around this? I do not want to rewrite the entire parser. = (

    1 answer 1

    The & symbol in XML is used to represent special entities of the form &amp; . Each such entity represents a control markup character ( < , > , " , etc.) or some commonly used special characters (for example, ©).

    In your case, the blabla&blabla.png not valid in XML terms. blabla&amp;blabla.png should be used blabla&amp;blabla.png .

    Want to use standard XML parsing tools — input valid XML to the input.

    • those. because I cannot influence the formation of this XML (it is given by a third-party site to which I have no relation and access), can I manage with castes or write to tech support for the site? =) - maler1988
    • @ maler1988, I would write to tech support, having previously banished the result of issuing through the XML validator (to make sure there is a problem). As a crutch, I would try to replace the symbols & not related to entities with &amp; . - Dmitriy Simushev