php - XML Parsing error -
I am trying to parse the XML file, but am getting the parsing error.
Code :: 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. $ xmlUrl = 'products.xml'; $ xmlStr = file_get_contents ($ xmlUrl); $ xmlObj = simplexml_load_string ($ xmlStr);
& 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
Post a Comment