Convert Xml to php string -
this question has answer here:
- xml parser error start tag expected 2 answers
i using below code converting xml response php string getting below error
"warning: simplexml_load_string(): entity: line 1: parser error : start tag expected, '<' not found....."
"warning: simplexml_load_string(): example.com...."
"warning: simplexml_load_string(): ^ in /home/example/public_html/example.php on line 9"
<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; $url= "example.com"; $xml = simplexml_load_string($url); echo $xml->status; ?>
well, simplexml_load_string
expects xml string passed parameter, not case of code: content of $url
variable not valid xml string, thus, errors.
you may want load $url
file instead. example:
$xml = simplexml_load_file($url);
final code:
<?php echo '<?xml version="1.0" encoding="utf-8" ?>'; $url ="example.com"; $xml = simplexml_load_file($url); echo $xml->status;
Comments
Post a Comment