56 $dom->myDOMNode->loadXML($str);
61 function xpath_eval($xpath_context,$eval_str,$contextnode=null)
64 return $xpath_context->query($eval_str,$contextnode);
79 $this->myDOMNode=$aDOMAttr;
84 return $this->myDOMNode->name;
89 return $this->myDOMNode->specified;
94 return $this->myDOMNode->value;
105 $this->myDOMNode=
new DOMDocument();
113 $myAttr=$this->myDOMNode->createAttribute($name);
114 $myAttr->value=$value;
122 return new php4DOMNode($this->myDOMNode->createCDATASection($content),$this);
136 return new php4DOMElement($this->myDOMNode->createElement($name),$this);
142 return new php4DOMNode($this->myDOMNode->createTextNode($content),$this);
148 return new php4DOMElement($this->myDOMNode->documentElement,$this);
154 return $this->myDOMNode->save(
$filename);
160 return $this->myDOMNode->saveXML();
166 return new php4DOMElement($this->myDOMNode->getElementById($id),$this);
172 $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
175 if (isset($myDOMNodeList))
176 while ($node=$myDOMNodeList->item($i))
187 return $this->myDOMNode->saveHTML();
193 return new php4DOMElement($this->myDOMNode->documentElement,$this);
202 return $this->myDOMNode->getAttribute($name);
208 $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
211 if (isset($myDOMNodeList))
212 while ($node=$myDOMNodeList->item($i))
223 return $this->myDOMNode->hasAttribute($name);
229 return $this->myDOMNode->removeAttribute($name);
235 return $this->myDOMNode->setAttribute($name,$value);
241 return $this->myDOMNode->tagName;
253 $this->myDOMNode=$aDomNode;
254 $this->myOwnerDocument=$aOwnerDocument;
260 if ($name==
'type')
return $this->myDOMNode->nodeType;
261 elseif ($name==
'tagname')
return $this->myDOMNode->tagName;
262 elseif ($name==
'content')
return $this->myDOMNode->textContent;
265 $myErrors=debug_backtrace();
266 trigger_error(
'Undefined property: '.get_class($this).
'::$'.$name.
' ['.$myErrors[0][
'file'].
':'.$myErrors[0][
'line'].
']',E_USER_NOTICE);
286 $myDOMNodeList=$this->myDOMNode->attributes;
289 if (isset($myDOMNodeList))
290 while ($node=$myDOMNodeList->item($i))
292 $nodeSet[]=
new php4DOMAttr($node,$this->myOwnerDocument);
301 $myDOMNodeList=$this->myDOMNode->childNodes;
304 if (isset($myDOMNodeList))
305 while ($node=$myDOMNodeList->item($i))
325 return new php4DOMElement($this->myDOMNode->firstChild,$this->myOwnerDocument);
329 return $this->myDOMNode->textContent;
334 return $this->myDOMNode->hasAttributes();
339 return $this->myDOMNode->hasChildNodes();
350 $myDOMNodeList=$this->myDOMNode->childNodes;
352 if (isset($myDOMNodeList))
353 while ($node=$myDOMNodeList->item($i))
355 if (($node->nodeType==XML_ELEMENT_NODE)||
356 (($node->nodeType==XML_TEXT_NODE)&&!ereg(
'^([[:cntrl:]]|[[:space:]])*$',$node->nodeValue)))
365 return new php4DOMElement($this->myDOMNode->lastChild,$this->myOwnerDocument);
371 $mySubNode=$this->myDOMNode->ownerDocument->createElement($name);
372 $mySubNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($content));
373 $this->myDOMNode->appendChild($mySubNode);
379 return new php4DOMElement($this->myDOMNode->nextSibling,$this->myOwnerDocument);
384 return $this->myDOMNode->localName;
389 return $this->myDOMNode->nodeType;
395 return $this->myDOMNode->nodeValue;
406 return new php4DOMElement($this->myDOMNode->parentNode,$this->myOwnerDocument);
411 return $this->myDOMNode->prefix;
416 return new php4DOMElement($this->myDOMNode->previousSibling,$this->myOwnerDocument);
433 if (($this->myDOMNode->hasChildNodes())&&($this->myDOMNode->firstChild->nodeType==XML_TEXT_NODE))
434 $this->myDOMNode->removeChild($this->myDOMNode->firstChild);
435 return $this->myDOMNode->appendChild($this->myDOMNode->ownerDocument->createTextNode($text));
447 $this->myDOMNodelist=$aDOMNodelist;
448 $this->nodeset=array();
450 if (isset($this->myDOMNodelist))
451 while ($node=$this->myDOMNodelist->item($i))
466 $this->myOwnerDocument=$dom_document;
467 $this->myDOMXPath=
new DOMXPath($dom_document->myDOMNode);
470 function query($eval_str,$contextnode)
480 return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);
484 if (extension_loaded(
'xsl'))
487 function domxml_xslt_stylesheet($xslstring)
490 return new php4DomXsltStylesheet(DOMDocument::loadXML($xslstring));
493 function domxml_xslt_stylesheet_doc($dom_document) {
495 return new php4DomXsltStylesheet($dom_document);
498 function domxml_xslt_stylesheet_file($xslfile) {
500 return new php4DomXsltStylesheet(DOMDocument::load($xslfile));
503 class php4DomXsltStylesheet
505 var $myxsltProcessor;
506 function php4DomXsltStylesheet($dom_document)
509 $this->myxsltProcessor=
new xsltProcessor();
510 $this->myxsltProcessor->importStyleSheet($dom_document);
513 function process($dom_document,$xslt_parameters=array(),$param_is_xpath=
false)
516 foreach ($xslt_parameters as $param=>$value)
517 $this->myxsltProcessor->setParameter(
'',$param,$value);
519 $myphp4DOMDocument->myDOMNode=$this->myxsltProcessor->transformToDoc($dom_document->myDOMNode);
520 return $myphp4DOMDocument;
523 function result_dump_file($dom_document,
$filename)
526 $html=$dom_document->myDOMNode->saveHTML();
531 function result_dump_mem($dom_document) {
533 return $dom_document->myDOMNode->saveHTML();