Isolate <string> of xml in xmlns ArrayOfString with PHP

179 Views Asked by At

I have a webpage with the following content:

<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><string/><string/>

<string><?xml version="1.0" encoding="utf-16"?>.....</string>...
</ArrayOfString>

How can I isolate the tags so I can parse the xml with PHP? So far I've tried using PHP SimpleXML, loading the file as xml, file_get_contents, loading the file as html with DOMDocument::loadHTML, but none of those have worked.

What I want to do is isolate the string tags with the xml inside, then parse each instance of xml to get the elements inside.

Any guidance would be appreciated. Thanks.

What I have tried so far is:

1. $data=file_get_contents($url);
$delimit='<string><?xml version="1.0" encoding="utf-16"?>';
print_r(explode($delimit,$data));

2. $xml=simplexml_load_file($url);
print_r($xml);

3. $xml=simplexml_load_file($url);
$data=new DOMDocument(); 
$data->loadXML($xml);
$strings=$data->getElementsByTagName("string");
var_dump($string);
0

There are 0 best solutions below