/ Published in: PHP
Expand |
Embed | Plain Text
public function dom_dump($obj) { $retval = "Instance of $classname, node list: \n"; switch (true) { case ($obj instanceof DOMDocument): $retval .= "XPath: {$obj->getNodePath()}\n".$obj->saveXML($obj); break; case ($obj instanceof DOMElement): $retval .= "XPath: {$obj->getNodePath()}\n".$obj->ownerDocument->saveXML($obj); break; case ($obj instanceof DOMAttr): $retval .= "XPath: {$obj->getNodePath()}\n".$obj->ownerDocument->saveXML($obj); break; case ($obj instanceof DOMNodeList): for ($i = 0; $i < $obj->length; $i++) { $retval .= "Item #$i, XPath: {$obj->item($i)->getNodePath()}\n". "{$obj->item($i)->ownerDocument->saveXML($obj->item($i))}\n"; } break; default: return "Instance of unknown class"; } } else { return 'no elements...'; } return $retval; }
You need to login to post a comment.
