note 87645 added to class.domxpath
| From: | MarkOmohundro at osu1 dot php dot net | Date: | Sun, 14 Dec 2008 17:15:26 +0000 |
| Subject: | note 87645 added to class.domxpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148148@lists.php.net to get a copy of this message | ||
<?php
// to retrieve selected html data, try these DomXPath examples:
$file = $DOCUMENT_ROOT. "test.html";
$doc = new DOMDocument();
$doc->loadHTMLFile($file);
$xpath = new DOMXpath($doc);
// example 1: for everything with an id
//$elements = $xpath->query("//*[@id]");
// example 2: for node data in a selected id
//$elements = $xpath->query("/html/body/div[@id='yourTagIdHere']");
// example 3: same as above with wildcard
$elements = $xpath->query("*/div[@id='yourTagIdHere']");
if (!is_null($elements)) {
foreach ($elements as $element) {
echo "<br/>[". $element->nodeName. "]";
$nodes = $element->childNodes;
foreach ($nodes as $node) {
echo $node->nodeValue. "\n";
}
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 4.231.169.46
----
Manual Page -- http://www.php.net/manual/en/class.domxpath.php
Edit -- https://master.php.net/note/edit/87645
Del: integrated -- https://master.php.net/note/delete/87645/integrated
Del: useless -- https://master.php.net/note/delete/87645/useless
Del: bad code -- https://master.php.net/note/delete/87645/bad+code
Del: spam -- https://master.php.net/note/delete/87645/spam
Del: non-english -- https://master.php.net/note/delete/87645/non-english
Del: in docs -- https://master.php.net/note/delete/87645/in+docs
Del: other reasons-- https://master.php.net/note/delete/87645
Reject -- https://master.php.net/note/reject/87645
Search -- https://master.php.net/manage/user-notes.php