How to retrieve attribute of root element of DOMDocument? [duplicate]
Possible Duplicate:
DOMDocument::load - PHP - Getting attribute value
I use the following code:
$str = '<a href="some_link">text</a>';
$dom = new DOMDocument;
$dom->loadXML($str);
I want to obtain the value of root element of $str
.
In this example "some_l开发者_运维技巧ink"
should be returned. In real case $str
is read from file.
How to achieve this?
Try:
$dom->documentElement->getAttribute('%yourAttrName%');
精彩评论