25 static $errs =
array();
31 $tag =
'DOMDocument::validate(): ';
32 $errs[] = str_replace($tag,
'', $errstr);
58 function xpath_eval($xpath_context,$eval_str,$contextnode=null)
60 return $xpath_context->query($eval_str,$contextnode);
74 $this->myDOMAttr=$aDOMAttr;
79 return $this->myDOMAttr->name;
84 return $this->myDOMAttr->specified;
89 return $this->myDOMAttr->value;
99 parent::php4DOMNode($aDOMCDATASection);
100 $this->myDOMCDATASection=$aDOMCDATASection;
113 set_error_handler(
'staticxmlerror');
114 $old = ini_set(
'html_errors',
false);
116 if (is_object($source))
118 $this->myDOMDocument = $source;
119 $this->success =
true;
125 $this->success = @$this->myDOMDocument->load($source,$a_mode);
126 $this->success = @$this->myDOMDocument->load($source,$a_mode);
130 $this->success = $this->myDOMDocument->loadXML($source,$a_mode);
135 ini_set(
'html_errors',
$old);
136 restore_error_handler();
140 $this->error_arr =
staticxmlerror(null, null, null, null, null,
true);
141 foreach($this->error_arr as
$error)
143 $error = str_replace(
"DOMDocument::loadXML():",
"", $error);
144 $this->error.= $error.
"<br />";
156 unset($this->myDOMDocument);
168 $str = $this->myDOMDocument->saveXML($node->myDOMNode);
175 $ok = $this->myDOMDocument->validate();
181 if (function_exists(
"libxml_get_last_error"))
183 $err = libxml_get_last_error();
196 $myAttr=$this->myDOMDocument->createAttribute($name);
197 $myAttr->value=$value;
214 return new php4DOMElement($this->myDOMDocument->createElement($name));
219 return new php4DOMNode($this->myDOMDocument->createTextNode($content));
229 return $this->myDOMDocument->save(
$filename);
234 $r = $this->myDOMDocument->saveXML();
240 $myDOMNodeList=$this->myDOMDocument->getElementsByTagName($name);
243 while ($node=$myDOMNodeList->item($i))
254 return $this->myDOMDocument->saveHTML();
266 return $this->myDOMNode->getAttribute($name);
276 $myDOMNodeList=$this->myDOMNode->getElementsByTagName($name);
279 while ($node=$myDOMNodeList->item($i))
290 return $this->myDOMNode->hasAttribute($name);
295 return $this->myDOMNode->removeAttribute($name);
300 return $this->myDOMNode->setAttribute($name,$value);
305 return $this->myDOMNode->tagName;
318 $text_node =
new DOMText();
319 $text_node->appendData(
$text);
320 if (is_object($this->myDOMNode->firstChild))
322 $this->myDOMNode->replaceChild($text_node, $this->myDOMNode->firstChild);
326 $this->myDOMNode->appendChild($text_node);
333 $text_node = $this->myDOMNode->firstChild;
335 if (is_object($text_node))
337 return $text_node->textContent;
348 parent::unlink_node($aDomNode);
362 $this->myDOMNode=$aDomNode;
370 $doc = $this->myDOMNode->ownerDocument;
372 $newnode->myDOMNode = $doc->importNode($newnode->myDOMNode,
true);
374 return new php4DOMElement($this->myDOMNode->appendChild($newnode->myDOMNode));
383 return $this->
set_content($newnode->myDOMNode->textContent);
388 return new php4DOMElement($this->myDOMNode->parentNode->appendChild($newnode->myDOMNode));
394 $myDOMNodeList=$this->myDOMNode->attributes;
397 if (is_object($myDOMNodeList))
399 while ($node=$myDOMNodeList->item($i))
411 $myDOMNodeList=$this->myDOMNode->childNodes;
414 while ($node=$myDOMNodeList->item($i))
433 if (!is_object($aDomNode))
439 $parent = $aDomNode->myDOMNode->parentNode;
440 if (is_object($parent))
442 $parent->removeChild($aDomNode->myDOMNode);
458 return $this->myDOMNode->textContent;
463 return $this->myDOMNode->hasAttributes();
468 return $this->myDOMNode->hasChildNodes();
475 $doc = $this->myDOMNode->ownerDocument;
476 $newnode->myDOMNode = $doc->importNode($newnode->myDOMNode,
true);
479 $mynewnode = $newnode->myDOMNode;
480 $myrefnode = $refnode->myDOMNode;
483 $domel = $mydomnode->insertBefore($mynewnode,$myrefnode);
485 catch (DOMException $exception)
488 $mydomnode = $this->myDOMNode->parentNode;
489 $domel = $mydomnode->insertBefore($mynewnode,$myrefnode);
498 $last = $this->myDOMNode->lastChild;
500 if (is_object($last))
513 $next = $this->myDOMNode->nextSibling;
515 if (is_object($next))
529 return $this->myDOMNode->localName;
533 return $this->myDOMNode->nodeName;
539 return $this->myDOMNode->nodeType;
544 return $this->myDOMNode->nodeValue;
550 $parent = $this->myDOMNode->parentNode;
552 if (is_object($parent))
565 $prev = $this->myDOMNode->previousSibling;
567 if (is_object($prev))
579 return new php4DOMElement($this->myDOMNode->removeChild($oldchild->myDOMNode));
584 return new php4DOMElement($this->myDOMNode->replaceChild($oldchild->myDOMNode,$newnode->myDOMNode));
589 $this->myDOMNode->textContent =
$text;
590 return $this->myDOMNode->textContent;
601 $this->myDOMNodelist=$aDOMNodelist;
602 $this->nodeset=
array();
604 while ($node=$this->myDOMNodelist->item($i))
624 $this->myDOMXPath=
new DOMXPath($dom_document->myDOMDocument);
634 return $this->myDOMXPath->registerNamespace($prefix,$namespaceURI);
xpath_register_ns($prefix, $namespaceURI)
set_attribute($name, $value)
xpath_new_context($dom_document)
__construct($aDOMCDATASection)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
dump_mem($format=false, $encoding=false)
__construct($dom_document)
staticxmlerror($errno, $errstr, $errfile, $errline, $errcontext, $ret=false)
dump_file($filename, $compressionmode=false, $format=false)
get_elements_by_tagname($name)
create_cdata_section($content)
get_elements_by_tagname($name)
__construct($aDOMNodelist)
insert_before($newnode, $refnode)
unlink_node($aDomNode="")
Create styles array
The data for the language used.
create_attribute($name, $value)
node_name($a_local=false)
__construct($source, $file=true, $a_mode=0)
create_text_node($content)
domxml_open_mem($str, $mode=0, &$error=NULL)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
replace_child($oldnode, $newnode)
domxml_open_file($filename)