Query Attr - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Query attr(string|array $attribute [, string|callable $value = NULL ]);
Access a property on the first matched element or set the attribute(s) of all matched elements.
$xml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<html:html xmlns:html='http://www.w3.org/1999/xhtml'>
<html:head>
<html:title>Examples: FluentDOM\Query::attr()</html:title>
</html:head>
<html:body>
<html:p>
Always nice to visit
<html:a href='http://fluentdom.org'>here.</html:a>
</html:p>
</html:body>
</html:html>
XML;
$fdQuery = FluentDOM($xml);
$fdQuery->registerNamespace('h', 'http://www.w3.org/1999/xhtml');
echo $fdQuery
->find('//h:a')
->attr('href');
http://fluentdom.org