php - XML Parsing error -


I am trying to parse the XML file, but am getting the parsing error.

Code :: $ xmlUrl = 'products.xml'; $ xmlStr = file_get_contents ($ xmlUrl); $ xmlObj = simplexml_load_string ($ xmlStr);

XML file ::

    

I am getting the error due to this tag

     

See a simpleXML object and a conversion for output, see the code below. See your "products.xml" file for the correct UTF-8 encoding type.

  & lt ;? Php $ xml = & lt; & Lt; & Lt; XML & lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Results & gt; & Lt; orderlist & gt; & Lt; order_no & gt; 123,123 & lt; / order_no & gt; & Lt; Date & gt; & Lt; / Date & gt; & Lt; client_name & gt; NAP & amp; Donut shop & lt; / client_name & gt; & Lt; Region & gt; 54 & lt; / Region & gt; & Lt; / Orderlist & gt; & Lt; / Results & gt; Xml; $ xml = str_replace (array ("& amp; amp;", "&"), array ("& amp;", "& amp;", $ xml); $ xmlObj = simple XMLload_string ($ xml ); var_dump ($ xmlObj); PHP_EOL echo $ XmlObj-> orderlist-> CLIENT_NAME; // results: Knapp & donut shop    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -