25 static $errs = array();
31 $tag =
'DOMDocument::validate(): ';
32 $errs[] = str_replace($tag,
'', $errstr);
54 function xpath_eval($xpath_context,$eval_str,$contextnode=null)
56 return $xpath_context->query($eval_str,$contextnode);
70 $this->myDOMAttr=$aDOMAttr;
75 return $this->myDOMAttr->name;
80 return $this->myDOMAttr->specified;
85 return $this->myDOMAttr->value;
96 $this->myDOMCDATASection=$aDOMCDATASection;
107 $this->myDOMDocument=
new DOMDocument();
110 set_error_handler(
'staticxmlerror');
111 $old = ini_set(
'html_errors',
false);
113 if (is_object($source))
115 $this->myDOMDocument = $source;
116 $this->success =
true;
122 $this->success = @$this->myDOMDocument->load($source);
126 $this->success = $this->myDOMDocument->loadXML($source);
131 ini_set(
'html_errors', $old);
132 restore_error_handler();
136 $this->error_arr =
staticxmlerror(null, null, null, null, null,
true);
137 foreach($this->error_arr as
$error)
139 $error = str_replace(
"DOMDocument::loadXML():",
"", $error);
140 $this->error.= $error.
"<br />";
152 unset($this->myDOMDocument);
164 $str = $this->myDOMDocument->saveXML($node->myDOMNode);
171 $ok = $this->myDOMDocument->validate();
175 $error = array(array(
"0",
"Unknown Error"));
177 if (function_exists(
"libxml_get_last_error"))
179 $err = libxml_get_last_error();
183 $error = array(array($err->code, $err->message));
192 $myAttr=$this->myDOMDocument->createAttribute(
$name);
193 $myAttr->value=$value;
215 return new php4DOMNode($this->myDOMDocument->createTextNode($content));
225 return $this->myDOMDocument->save(
$filename);
230 return $this->myDOMDocument->saveXML();
235 $myDOMNodeList=$this->myDOMDocument->getElementsByTagName(
$name);
238 while ($node=$myDOMNodeList->item($i))
249 return $this->myDOMDocument->saveHTML();
261 return $this->myDOMNode->getAttribute(
$name);
271 $myDOMNodeList=$this->myDOMNode->getElementsByTagName(
$name);
274 while ($node=$myDOMNodeList->item($i))
285 return $this->myDOMNode->hasAttribute(
$name);
290 return $this->myDOMNode->removeAttribute(
$name);
295 return $this->myDOMNode->setAttribute(
$name,$value);
300 return $this->myDOMNode->tagName;
309 $text = str_replace(
"<",
"<", $text);
310 $text = str_replace(
">",
">", $text);
311 $text = str_replace(
"&",
"&", $text);
313 $text_node =
new DOMText();
314 $text_node->appendData($text);
315 if (is_object($this->myDOMNode->firstChild))
317 $this->myDOMNode->replaceChild($text_node, $this->myDOMNode->firstChild);
321 $this->myDOMNode->appendChild($text_node);
328 $text_node = $this->myDOMNode->firstChild;
330 if (is_object($text_node))
332 return $text_node->textContent;
357 $this->myDOMNode=$aDomNode;
365 $doc = $this->myDOMNode->ownerDocument;
367 $newnode->myDOMNode = $doc->importNode($newnode->myDOMNode,
true);
369 return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode));
378 return $this->
set_content($newnode->myDOMNode->textContent);
383 return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode));
389 $myDOMNodeList=$this->myDOMNode->attributes;
392 if (is_object($myDOMNodeList))
394 while ($node=$myDOMNodeList->item($i))
406 $myDOMNodeList=$this->myDOMNode->childNodes;
409 while ($node=$myDOMNodeList->item($i))
428 if (!is_object($aDomNode))
434 $parent = $aDomNode->myDOMNode->parentNode;
435 if (is_object($parent))
437 $parent->removeChild($aDomNode->myDOMNode);
453 return $this->myDOMNode->textContent;
458 return $this->myDOMNode->hasAttributes();
463 return $this->myDOMNode->hasChildNodes();
470 $doc = $this->myDOMNode->ownerDocument;
471 $newnode->myDOMNode = $doc->importNode($newnode->myDOMNode,
true);
474 $mynewnode = $newnode->myDOMNode;
475 $myrefnode = $refnode->myDOMNode;
478 $domel = $mydomnode->insertBefore($mynewnode,$myrefnode);
480 catch (DOMException $exception)
483 $mydomnode = $this->myDOMNode->parentNode;
484 $domel = $mydomnode->insertBefore($mynewnode,$myrefnode);
493 $last = $this->myDOMNode->lastChild;
495 if (is_object($last))
508 $next = $this->myDOMNode->nextSibling;
510 if (is_object($next))
524 return $this->myDOMNode->localName;
528 return $this->myDOMNode->nodeName;
534 return $this->myDOMNode->nodeType;
539 return $this->myDOMNode->nodeValue;
545 $parent = $this->myDOMNode->parentNode;
547 if (is_object($parent))
560 $prev = $this->myDOMNode->previousSibling;
562 if (is_object($prev))
574 return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode));
579 return new php4DOMElement($this->myDOMNode->replaceChild($oldchild->myDOMNode,$newnode->myDOMNode));
584 $this->myDOMNode->textContent = $text;
585 return $this->myDOMNode->textContent;
596 $this->myDOMNodelist=$aDOMNodelist;
597 $this->nodeset=array();
599 while ($node=$this->myDOMNodelist->item($i))
619 $this->myDOMXPath=
new DOMXPath($dom_document->myDOMDocument);
630 return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);