php - Guzzle error on parsing xml with html comment in it -
i'm getting error guzzle. xml has html comment in think breaking it. experience in relation guzzle because @ point try response @ xml error through e.g. $res->xml(). $res alone or $res->getbody() don't seem me.
"uncaught exception 'exception' message 'string not parsed xml' in /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php:168 stack trace: #0 /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php(168): simplexmlelement->__construct('please use mi...', 2048, false, '', false) #1 /home/mso/public_html/connector/get_dat.php(23): guzzlehttp\message\response->xml() #2 {main} next exception 'guzzlehttp\exception\xmlparseexception' message 'unable parse response body xml: string not parsed xml' in /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php:174 stack trace: #0 /home/mso/public_html/connector/get_data.php(23): guzzlehttp\message\response->xml() #1 {main} thrown in /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php on line 17
you can try check xml prior load using:
$oxmlutilities = new cxmlutilities(); // validate xml file setting internal errors. libxml_use_internal_errors( true ); try { $stmpstring = simplexml_load_string( $scontents ); } catch( exception $oexception ) { $serror = $oexception->getmessage(); } // if xml validates , isn't empty call guzzle: if( empty( $serror ) && ( $stmpstring ) ) { // xml valid.
otherwise may need parse string through regex html comments:
<!--(.*?)-->
Comments
Post a Comment