-
Notifications
You must be signed in to change notification settings - Fork 20
Query Attr
Thomas Weinert edited this page Jul 12, 2018
·
2 revisions
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
- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces