in Deutsh
in French
in Polish

You Are At Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

DOMXPath->query()

(no version information, might be only in CVS)

DOMXPath->query() --  Evaluates the given XPath expression

Description

class DOMXPath {

DOMNodeList query ( string expression [, DOMNode contextnode] )

}

Executes the given XPath expression.

Parameters

expression

The XPath expression to execute.

contextnode

The optional contextnode can be specified for doing relative XPath queries. By default, the queries are relative to the root element.

Return Values

Returns a DOMNodeList containing all nodes matching the given XPath expression. Any expression which do not return nodes will return an empty DOMNodeList.

Examples

Example 1. Getting all the english books

<?php

$doc
= new DOMDocument;

// We don't want to bother with white spaces
$doc->preserveWhiteSpace = false;

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

$xpath = new DOMXPath($doc);

// We starts from the root element
$query = '//book/chapter/para/informaltable/tgroup/tbody/row/entry[. = "en"]';

$entries = $xpath->query($query);

foreach (
$entries as $entry) {
    echo
"Found {$entry->previousSibling->previousSibling->nodeValue}," .
         
" by {$entry->previousSibling->nodeValue}\n";
}
?>

The above example will output:

Found The Grapes of Wrath, by John Steinbeck
Found The Pearl, by John Steinbeck

We can also use the contextnode parameter to shorten our expression:

<?php

$doc
= new DOMDocument;
$doc->preserveWhiteSpace = false;

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

$xpath = new DOMXPath($doc);

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

// our query is relative to the tbody node
$query = 'row/entry[. = "en"]';

$entries = $xpath->query($query, $tbody);

foreach (
$entries as $entry) {
    echo
"Found {$entry->previousSibling->previousSibling->nodeValue}," .
         
" by {$entry->previousSibling->nodeValue}\n";
}
?>

See Also

DOMXPath->evaluate()

Wyjatkowej jakości meble medyczne w xmebel
Kotły gazowe
Grzejniki
zespół weselny warszawa
Największa baza pytań egzamin doradca podatkowy testy na doradce podatkowego

Another Useful functions:


function.dom-domxpath-registernamespace | function.dom-domxpath-query | function.dom-domxpath-evaluate | function.dom-domxpath-construct | function.dom-domtext-splittext | function.dom-domtext-iswhitespaceinelementcontent | function.dom-domtext-construct | function.dom-domprocessinginstruction-construct | function.dom-domnodelist-item | function.dom-domnode-replacechild | function.dom-domnode-removechild | function.dom-domnode-normalize | function.dom-domnode-lookupprefix | function.dom-domnode-lookupnamespaceuri | function.dom-domnode-issupported | function.dom-domnode-issamenode | function.dom-domnode-isdefaultnamespace | function.dom-domnode-insertbefore | function.dom-domnode-haschildnodes | function.dom-domnode-hasattributes | function.dom-domnode-clonenode | function.dom-domnode-appendchild | function.dom-domnamednodemap-item | function.dom-domnamednodemap-getnameditemns | function.dom-domnamednodemap-getnameditem | function.dom-domimplementation-hasfeature | function.dom-domimplementation-createdocumenttype | function.dom-domimplementation-createdocument | function.dom-domimplementation-construct | function.dom-domentityreference-construct | function.dom-domelement-setidattributens | function.dom-domelement-setidattributenode | function.dom-domelement-setidattribute | function.dom-domelement-setattributens | function.dom-domelement-setattributenodens | function.dom-domelement-setattributenode | function.dom-domelement-setattribute | function.dom-domelement-removeattributens | function.dom-domelement-removeattributenode | function.dom-domelement-removeattribute | function.dom-domelement-hasattributens | function.dom-domelement-hasattribute | function.dom-domelement-getelementsbytagnamens | function.dom-domelement-getelementsbytagname | function.dom-domelement-getattributens | function.dom-domelement-getattributenodens | function.dom-domelement-getattributenode | function.dom-domelement-getattribute | function.dom-domelement-construct | function.dom-domdocumentfragment-appendxml | function.dom-domdocument-xinclude | function.dom-domdocument-validate | function.dom-domdocument-schemavalidatesource | function.dom-domdocument-schemavalidate | function.dom-domdocument-savexml | function.dom-domdocument-savehtmlfile | function.dom-domdocument-savehtml | function.dom-domdocument-save | function.dom-domdocument-relaxngvalidatesource | function.dom-domdocument-relaxngvalidate | function.dom-domdocument-registernodeclass | function.dom-domdocument-normalizedocument | function.dom-domdocument-loadxml | function.dom-domdocument-loadhtmlfile | function.dom-domdocument-loadhtml | function.dom-domdocument-load | function.dom-domdocument-importnode | function.dom-domdocument-getelementsbytagnamens | function.dom-domdocument-getelementsbytagname | function.dom-domdocument-getelementbyid | function.dom-domdocument-createtextnode | function.dom-domdocument-createprocessinginstruction | function.dom-domdocument-createentityreference | function.dom-domdocument-createelementns | function.dom-domdocument-createelement | function.dom-domdocument-createdocumentfragment | function.dom-domdocument-createcomment | function.dom-domdocument-createcdatasection | function.dom-domdocument-createattributens | function.dom-domdocument-createattribute | function.dom-domdocument-construct | function.dom-domcomment-construct | function.dom-domcharacterdata-substringdata | function.dom-domcharacterdata-replacedata | function.dom-domcharacterdata-insertdata | function.dom-domcharacterdata-deletedata | function.dom-domcharacterdata-appenddata | function.dom-domattr-isid | function.dom-domattr-construct |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.