2013-01-07 48 views
-3

可能重複:
SimpleXML Reading node with a hyphenated name無法解析節點的SimpleXML

我有一個節點包含破折號XML:

<max-passwd-length>32</max-passwd-length> 
    <max-email-length>128</max-email-length> 

我用這些行:

$s = simplexml_load_file('rss-0.91.xml'); 
print $s->max-email-length->title 

但我得到PHP錯誤,因爲有破折號,我能做些什麼來解決這個問題?

P.S.我無法編輯XML文件以刪除破折號。

+0

XML標籤名稱規則:http://www.w3schools.com/xml/xml_elements.asp .. –

回答

2

試試這個$s->{'max-email-length'}->title

+0

謝謝,它的工作。 – Houranis