Sunday, 15 September 2013

Get values in between tags from web page

Get values in between tags from web page

I'm trying to pull two pieces of data from an external web page. There are
two tags on the page, and the data I need is within both.
How would I get the data from both tags?
I've tried a few different things, but none seem to work. Here's what I
tried last:
$dom = new DOMDocument;
$dom->loadHtmlFile('url');
$xpath = new DOMXPath($dom);
$elements = $xpath->query('b');
if ($elements->length) {
echo "found: ", $elements->item(0)->getAttribute('value');
} else {
echo "not found";
}

No comments:

Post a Comment