FIA2008 FIA2008 - 2 years ago 102
PHP Question

XPath query for content between HTML tags

I have HTML like this:

<meta content="{{find_this}}" />

I load this in a DOM document and XPath like this:

$dom = new DOMDocument();
$xpath = new DOMXPath($dom);

I want to use xpath to query a tag that has
as value and no as attribute value. How can I do this?

Answer Source

This XPath expression,


will select all elements (not attributes) whose string value equals {{find_this}}.

Alternatively, if you wish to select all elements whose string value contains the string, use this XPath:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download