XML分析器错误开始标签预期 [英] XML Parser Error Start Tag Expected

查看:752
本文介绍了XML分析器错误开始标签预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;  
}




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

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


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

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


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

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



这是XML文件:

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

我没有理解为什么它不起作用,是的它有<?xml version =1.0encoding = UTF-8standalone =yes?> he阿德!
试过 $ profileData = new SimpleXMLElement(file_get_contents($ url)),但我得到了相同的结果。

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.

为什么会发生这种情况?我该如何解决它?我在寻找3个小时,只看到不会帮助我的答案。

错误: http://img824.imageshack.us/img824/9464/errorszz.png

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

编辑1:simplexml_load_string是我的错误之一,但现在我用simplexml_load_file得到更多的错误 - 告诉我文档是空的...(不正确!)

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 !)

推荐答案

您正在将URL作为XML源加载。你应该有:

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

$profileData = simplexml_load_file($url);

这篇关于XML分析器错误开始标签预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆