無料スクリプト配布のPHP.TO   PHPの実用的なtips PHPマニュアル MySQLマニュアル Apacheマニュアル PostgreSQLマニュアル マニュアル検索    

DOMXPath::evaluate

(PHP 5 >= 5.1.0)

DOMXPath::evaluate ?? XPath ?????

public mixed DOMXPath::evaluate ( string $expression [, DOMNode $contextnode [, bool $registerNodeNS = true ]] )

?? XPath expression ?? ???????

??

expression

?? XPath

contextnode

XPath ??????????? ????? root ?????

registerNodeNS

? registerNodeNS ? ???????????

?

????????? XPath expression ??????? DOMNodeList ??

expression ?? contextnode ??? DOMXPath::evaluate() FALSE ??

?

5.3.3 registerNodeNS ????

1 ??

<?php

$doc 
= new DOMDocument;

$doc->load('book.xml');

$xpath = new DOMXPath($doc);

$tbody $doc->getElementsByTagName('tbody')->item(0);

// tbody ?????
$query 'count(row/entry[. = "en"])';

$entries $xpath->evaluate($query$tbody);
echo 
"There are $entries english books\n";

?>

??????

There are 2 english books



powered by SEO.CUG.NET