note 102430 rejected from class.domelement by danbrown
[email protected] Mon, 14 Feb 2011 05:32:43 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
Note Submitter: happylot.info
----
I use this code to get content of tag, but the result return
<h1 class="Title">Some text...</h1>
function getTags( $dom, $tagName, $attrName, $attrValue ){
$html = '';
$domxpath = new DOMXPath($dom);
$newDom = new DOMDocument;
$newDom->formatOutput = true;
$filtered = $domxpath->query("//$tagName" . '[@' . $attrName . "='$attrValue']");
$i = 0;
while( $myItem = $filtered->item($i++) ){
$node = $newDom->importNode( $myItem, true ); // import node
$newDom->appendChild($node); // append node
}
$html = $newDom->saveHTML() ;
return $html;
}
How can I get only "Some text..."