2

I have some php code that returns xml from an endpoint like so:

$url = 'https://someurl.edu.au:8781/users/publications';

$context = stream_context_create(array(
    'http' => array(
        'header'  => "Authorization: Basic " . base64_encode("$username:$password")
        )
    )
);
$data = file_get_contents($url, false, $context);
$xml=simplexml_load_string($data);
if ($xml === false) {
    echo "Failed loading XML: ";
} else {
    echo "<pre>".var_export($xml, 1)."</pre>";
}

So that appears to work but, it cannot return elements in the XML file that begin with "api:"

So for example when I go to the URL in a browser the XML reads:

<hello>Some Text</hello>
<api:world>More Text</api:world>
<test>Test Stuff</test>

But my php just returns

<hello>Some Text</hello>
<test>Test Stuff</test>

So what is "api:" and why would my code see that as a problem?

Thanks

0 Answers0