note 43631 deleted from ref.dom by didou
| From: | didou@php.net | Date: | Fri, 17 Dec 2004 11:25:37 +0000 |
| Subject: | note 43631 deleted from ref.dom by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81901@lists.php.net to get a copy of this message | ||
Note Submitter: d-wetzel at gmx dot net
----
Use 'nodeType' to get the type of a node. Returns value of the predefined XML constants
listed above.
Example:
- You can use the following xml-structure (name it structure.xml):
<?xml version="1.0"?>
<foo><bar><text>DOM in PHP5 is
good.</text><text>Hello.</text></bar></foo>
- The code:
<?php
$document = new DomDocument();
$document->preserveWhiteSpace = false;
$document->load("structure.xml");
$xpath = new domXPath($document);
$xpathQuery = $xpath->query("/foo/bar/text[position()=1]");
foreach ($xpathQuery as $nodeList)
{
if($nodeList->firstChild->nodeType==XML_TEXT_NODE) echo "Node is a piece of
text.<br />";
}
?>
Dominikus Wetzel