XML Parser Error Start Tag Expected

给你一囗甜甜゛ 提交于 2019-11-30 09:19:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!