问题
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 !)
回答1:
You are loading the URL as your XML source. You should have:
$profileData = simplexml_load_file($url);
回答2:
Url was changing from steamcommunity.com/profiles/76561197991676121/?xml=1 to http://steamcommunity.com/id/virusbogdan/?xml=1 . Obviously the first link returns null so there was an error. Problem solved !
来源:https://stackoverflow.com/questions/12059873/xml-parser-error-start-tag-expected