2011-07-15 49 views
0

假設您有一個帶有ns冒號標記的xml文檔,例如<person:core age="25" />,如何使用PHP DOMDocument獲取屬性值?DomDocument以XML ns格式獲取屬性

+0

[解析命名空間標記(PHP)中的XML屬性]可能的重複(http://stackoverflow.com/questions/6698870/parsing-xml-attributes-within-a-namespace-tag-php) – hakre

+0

如果XML沒有聲明該前綴,它將被丟棄並且重複爲:[PHP DOMDocument獲取標籤屬性](http://stackoverflow.com/questions/1597746/php-domdocument-getting-attribute-of-tag) – hakre

回答

0

你可能要考慮的DOMDocument::getElementsByTagNameNS()[docs]方法,它應該做你所需要的。我無法爲您提供特定的代碼,因爲您尚未包含您正在使用的XML文件。

+0

是否獲取屬性? – ina