From: Uwe Steinmann Date: Wed, 26 Jan 2000 06:22:44 +0000 (+0000) Subject: - test script for domxml X-Git-Tag: BEFORE_SAPIFICATION_FEB_10_2000~183 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49be46409ce58d4f313bb168fa9a03bb9fa87866;p=php - test script for domxml --- diff --git a/tests/testdom b/tests/testdom new file mode 100644 index 0000000000..9a270cea49 --- /dev/null +++ b/tests/testdom @@ -0,0 +1,63 @@ +type) { + case XML_ELEMENT_NODE: + for($i=0; $i<$level; $i++) + echo " "; + echo "<".$node->name; + $attributes = $node->attributes(); + if(is_array($attributes)) + for(reset($attributes); $attrname = key($attributes); next($attributes)) + echo " ".$attrname."=".$node->getattr($attrname); + echo ">\n"; + $children = $node->children(); + for($i=0; $i < count($children); $i++) + output_node($children[$i], $level+1); + for($i=0; $i<$level; $i++) + echo " "; + echo "name.">\n"; + break; + case XML_TEXT_NODE: + for($i=0; $i<$level; $i++) + echo " "; + echo $node->content; + echo "\n"; + break; + } +} + +function list_attr($node) { + $attr = domxml_attributes($node); + for(reset($attr); $key = key($attr); next($attr)) { + echo $key."=".$attr[$key]."\n"; + } +} + +$xmlstr = " + +Title + + + + +a1b1c1 +a2c2 +a3b3c3 + + + + + "; + +$dom = dom($xmlstr); +echo "XML Version: ".$dom->version."\n"; +$dtd = $dom->intdtd(); +$rootnode = $dom->root(); +/* The following line causes a segm fault if more than 5 methods are in + class node, see ext/domxml/domxml.c */ +$attr = $rootnode->getattr("language"); + +output_node($rootnode); + +?>