Php 如何解析包含'-';以他们的名义?

Php 如何解析包含'-';以他们的名义?,php,xml,parsing,Php,Xml,Parsing,我无法用simplexml解析php中名称中包含“-”的标记 这是xml- 无法分析url文本和url链接。出现以下错误- 1) 使用未定义的常量文本-在C:\wamp\www\score1.php中假定为“text” 2) 使用未定义的常量链接-在C:\wamp\www\score1.php中假定为“链接” 3) 2)使用未定义的常量链接-在C:\wamp\www\score1.php中假定为“url” 请帮帮我 php正在将url文本解析为seprate变量-“url”和“text” 这是

我无法用simplexml解析php中名称中包含“-”的标记

这是xml-

无法分析url文本和url链接。出现以下错误- 1) 使用未定义的常量文本-在C:\wamp\www\score1.php中假定为“text” 2) 使用未定义的常量链接-在C:\wamp\www\score1.php中假定为“链接” 3) 2)使用未定义的常量链接-在C:\wamp\www\score1.php中假定为“url” 请帮帮我 php正在将url文本解析为seprate变量-“url”和“text”

这是密码

<?php 
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Pragma: no-cache"); Header('Pragma: no-cache');

    $url = "http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml";
    //$url = "C:\wamp\www\score.xml";
    $curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec ($curl);
    curl_close ($curl);
    print $result;
    $fp = fopen('score.xml', 'w');
    if($fp)
        fwrite($fp,  $result);  
    else
    echo "Error !";

    $url = "score.xml";
    $xml = simplexml_load_file($url,null, LIBXML_NOCDATA);
     foreach ($xml->match as $xmlinfo):
        $header=$xmlinfo->header;
        $description=$xmlinfo->description;
        $urltext=$xmlinfo->url-text;
        $urllink=$xmlinfo->url-link;
        echo $header,$description,$urltext;
    endforeach;
    //var_dump($xml);
 ?>
匹配为$xmlinfo):
$header=$xmlinfo->header;
$description=$xmlinfo->description;
$urltext=$xmlinfo->url文本;
$urlink=$xmlinfo->url链接;
echo$header、$description、$urltext;
endforeach;
//var_dump($xml);
?>
访问XML文档中不包含字符的元素 PHP的命名约定(例如连字符)允许 通过将元素名称封装在大括号和 撇号

就你而言:

$xmlinfo->{'url-text'}