|
Class: XMLDocQuery
Source Location: Program_Root/XML/Doc/Query.php
Parser
|
--XMLDocQuery
XMLDocQuery provides XPath-compatible searching and referencing capabilities to the XMLDoc package. Here is a list of supported Xpath features:
Author(s)
Version
- 2.0, 2003-01-20, $Id: Query.php,v 1.3 2005/10/16 02:52:14 lux Exp $
Copyright
- Copyright (C) 2001-2003, Simian Systems Inc.
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 107]
XMLDocQuery provides XPath-compatible searching and referencing capabilities to the XMLDoc package. Here is a list of supported Xpath features: - /nodeName and //nodeName references
- /nodeName[1] numbered references (counting starts from 1, not 0).
- /nodeName[@attrName="attrValue"] references
- /@attrName attribute references
- /nodeName/@attrName = "some value" conditions
Features specifically not supported from the Xpath standard are: - Axes, ie. child::someNodeName
- Relative operators, ie. ./childNode, ../siblingNode, and *
- Functions, ie. //item/title/upper-case(.)
For more information about Xpath, see http://www.w3.org/TR/xpath. Query Examples -------------- (Based on an XHTML document structure.) /html/body/h1 returns all h1 tags directly below the body tag. Elements are returned as DocNode object references. /html/body//p returns all p tags anywhere inside the body. //p returns all p tags anywhere, even outside the body. //a/@href returns all links in the document, as an array of DocAttr object references. /html/body//p[1] returns the first p tag found inside the body. //table/tr[1]/td[1] returns the first cell (top-left) of each table. //map[@name="top-navbar"] returns the node <map name="top-navbar"></map>. /html/body/h1 = "Welcome" returns a true or false value, depending on whether the first h1 tag contains the string "Welcome". /html/head/meta returns all of the meta tags. /html/head/meta[@name="description"] returns the meta description tag. This class is not usually called directly, but can be accessed through the query() method of the XMLDoc and XMLNode classes. New in 2.0: - Rewritten from scratch using the saf.Parser package. Should be more
stable now and is more featureful now.
- New features added: attribute references, conditions, and fixed the
numbebred references to begin counting from 1 instead of 0, which is
now compatible with the Xpath standard.
Historical: New in 1.2: - Fixed a bug where the use of namespaces caused matching to fail.
1 <?php 2 3 $xq = new XMLDocQuery ($xhtml_doc); 4 5 $res = $xq->query ('/html/head/title'); 6 7 ? >
Tags:
Class Variables
Class Methods
|
|