/[cvs]/bareface/yakka/library/YakkaXml.php
ViewVC logotype

Annotation of /bareface/yakka/library/YakkaXml.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sun Jan 5 00:22:26 2003 UTC (21 years, 6 months ago) by bareface
Branch: MAIN
CVS Tags: HEAD
init;

1 bareface 1.1 <?php
2    
3     require_once("YakkaObject.php");
4    
5     class YakkaXml extends YakkaObject {
6     var $data;
7     var $dom;
8     var $xpathContext;
9     var $namespaces;
10    
11     function YakkaXml($source) {
12     $this->YakkaObject("YakkaXml");
13    
14     if (is_object($source) && $source->is("YakkaFileReader"))
15     $this->data = $source->readAll();
16     else
17     $this->data = $source;
18    
19     $this->dom = domxml_open_mem($this->data);
20     $this->xpathContext = xpath_new_context($this->dom);
21     $this->namespaces = array();
22     }
23    
24     function declareNamespace($namespacePrefix, $namespaceURI) {
25     $this->namespaces[$namespacePrefix] = $namespaceURI;
26     xpath_register_ns($this->xpathContext, $namespacePrefix, $namespaceURI);
27     }
28    
29     function &selectNode($xpathExpression) {
30     $xpathResult = xpath_eval($this->xpathContext, $xpathExpression);
31     if ($xpathResult && ($node = $xpathResult->nodeset[0]))
32     return $node;
33    
34     return null;
35     }
36    
37     function &selectNodeValue($xpathExpression) {
38     $xpathResult = xpath_eval($this->xpathContext, $xpathExpression);
39     if ($xpathResult && ($node = $xpathResult->nodeset[0])) {
40     return $node->get_content();
41     }
42     return null;
43     }
44    
45     function &selectNodes($xpathExpression) {
46     $xpathResult = xpath_eval($this->xpathContext, $xpathExpression);
47     if ($xpathResult && ($nodes = $xpathResult->nodeset))
48     return $nodes;
49    
50     return null;
51     }
52    
53     function setAttributeOfElement($attributeName, $attributeValue, $xpathExpression) {
54     if ($node = $this->selectNode($xpathExpression))
55     $node->set_attribute($attributeName, $attributeValue);
56     }
57    
58     function toXml() {
59     return $this->dom->dump_mem();
60     }
61    
62     function toXmlElement() {
63     $domElement = $this->dom->document_element();
64     return $domElement->dump_node($domElement);
65     }
66    
67     function &toDom() {
68     return $this->dom;
69     }
70    
71     function &toDomElement() {
72     return $this->dom->document_element();
73     }
74    
75     function toHtml() {
76     return $this->dom->html_dump_mem();
77     }
78     }
79    
80     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed