XML Parser Error Start Tag Expected

virusbogdan picture virusbogdan · Aug 21, 2012 · Viewed 27.5k times · Source
function retrieveProfile() 
{
    $url = "http://steamcommunity.com/profiles/{$this->steamID64}/?xml=1";
    $profileData = simplexml_load_string($url);

    if(!empty($profileData->error)) { return NULL; }

    $this->friendlyName  = (string) $profileData->steamID;  
}

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found

Warning: simplexml_load_string() [function.simplexml-load-string]: http://steamcommunity.com/profiles/76561197991676121/?xml=1

Warning: simplexml_load_string() [function.simplexml-load-string]: ^

This is the XML file:

http://steamcommunity.com/profiles/76561197991676121/?xml=1

I got no ideea why it does not work and yes it have <?xml version="1.0" encoding="UTF-8" standalone="yes"?> header ! Tried $profileData = new SimpleXMLElement(file_get_contents($url)) too but I get the same result.

Why is this happening ? How can I solve it? I am searching for 3 hours and see only answers that won't help me .
Errors : http://img824.imageshack.us/img824/9464/errorszz.png

EDIT1 : simplexml_load_string was one of my mistakes but now I get even more errors with simplexml_load_file - Tells me that the document is empty... (Not true !)

Answer

Tchoupi picture Tchoupi · Aug 21, 2012

You are loading the URL as your XML source. You should have:

$profileData = simplexml_load_file($url);