⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 domxml001.phpt

📁 php-4.4.7学习linux时下载的源代码
💻 PHPT
字号:
--TEST--Test 1: Accessing single node--SKIPIF--<?php require_once('skipif.inc'); ?>--FILE--<?phprequire_once("domxml_test.inc");echo "Test 1: accessing single nodes from php\n";$dom = xmldoc($xmlstr);if(!$dom) {  echo "Error while parsing the document\n";  exit;}// children() of of document would result in a memleak//$children = $dom->children();//print_node_list($children);echo "--------- root\n";$rootnode = $dom->root();print_node($rootnode);echo "--------- children of root\n";$children = $rootnode->children();print_node_list($children);// The last node should be identical with the last entry in the children arrayecho "--------- last\n";$last = $rootnode->last_child();print_node($last);// The parent of this last node is the root againecho "--------- parent\n";$parent = $last->parent();print_node($parent);// The children of this parent are the same children as one aboveecho "--------- children of parent\n";$children = $parent->children();print_node_list($children);echo "--------- creating a new attribute\n";//This is worthless//$attr = $dom->create_attribute("src", "picture.gif");//print_r($attr);//$rootnode->set_attribute_node($attr); /* Not implemented */$attr = $rootnode->set_attribute("src", "picture.gif");$attr = $rootnode->get_attribute("src");print_r($attr);print "\n";echo "--------- Get Attribute Node\n";$attr = $rootnode->get_attribute_node("src");print_node($attr);echo "--------- Remove Attribute Node\n";$attr = $rootnode->remove_attribute("src");print "Removed " . $attr . " attributes.\n";echo "--------- attributes of rootnode\n";$attrs = $rootnode->attributes();print_node_list($attrs);echo "--------- children of an attribute\n";$children = $attrs[0]->children();print_node_list($children);echo "--------- Add child to root\n";$newchild = $rootnode->new_child("Silly", "Symphony");print_node($newchild);print $dom->dumpmem();print "\n";echo "--------- Find element by tagname\n";echo "    Using dom\n";$children = $dom->get_elements_by_tagname("Silly");print_node_list($children);echo "    Using elem\n";$children = $rootnode->get_elements_by_tagname("Silly");print_node_list($children);echo "--------- Unlink Node\n";print_node($children[0]);//domxml_node_unlink_node($children[0]);$children[0]->unlink_node();print_node_list($rootnode->children());print $dom->dumpmem();echo "--------- Find element by id\n";print ("Not implemented\n");echo "--------- Check various node_name return values\n";print ("Not needed\n");?>--EXPECT--Test 1: accessing single nodes from php--------- rootNode Name: chapterNode Type: 1Num Children: 4--------- children of rootNode Name: titleNode Type: 1Num Children: 1Node Content: TitleNode Name: #textNode Type: 3Num Children: 0Node Content: Node Name: paraNode Type: 1Num Children: 7Node Name: #textNode Type: 3Num Children: 0Node Content: --------- lastNode Name: #textNode Type: 3Num Children: 0Node Content: --------- parentNode Name: chapterNode Type: 1Num Children: 4--------- children of parentNode Name: titleNode Type: 1Num Children: 1Node Content: TitleNode Name: #textNode Type: 3Num Children: 0Node Content: Node Name: paraNode Type: 1Num Children: 7Node Name: #textNode Type: 3Num Children: 0Node Content: --------- creating a new attributepicture.gif--------- Get Attribute NodeNode Name: srcNode Type: 2Num Children: 1Node Content: picture.gif--------- Remove Attribute NodeRemoved 1 attributes.--------- attributes of rootnodeNode Name: languageNode Type: 2Num Children: 1Node Content: en--------- children of an attributeNode Name: #textNode Type: 3Num Children: 0Node Content: en--------- Add child to rootNode Name: SillyNode Type: 1Num Children: 1Node Content: Symphony<?xml version="1.0" standalone="yes"?><!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [<!ENTITY sp "spanish">]><!-- lsfj  --><chapter language="en"><title language="en">Title</title><para language="ge">&sp;<!-- comment --><informaltable language="&sp;kkk"><tgroup cols="3"><tbody><row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row><row><entry>a2</entry><entry>c2</entry></row><row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row></tbody></tgroup></informaltable></para><Silly>Symphony</Silly></chapter>--------- Find element by tagname    Using domNode Name: SillyNode Type: 1Num Children: 1Node Content: Symphony    Using elemNode Name: SillyNode Type: 1Num Children: 1Node Content: Symphony--------- Unlink NodeNode Name: SillyNode Type: 1Num Children: 1Node Content: SymphonyNode Name: titleNode Type: 1Num Children: 1Node Content: TitleNode Name: #textNode Type: 3Num Children: 0Node Content: Node Name: paraNode Type: 1Num Children: 7Node Name: #textNode Type: 3Num Children: 0Node Content: <?xml version="1.0" standalone="yes"?><!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [<!ENTITY sp "spanish">]><!-- lsfj  --><chapter language="en"><title language="en">Title</title><para language="ge">&sp;<!-- comment --><informaltable language="&sp;kkk"><tgroup cols="3"><tbody><row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row><row><entry>a2</entry><entry>c2</entry></row><row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row></tbody></tgroup></informaltable></para></chapter>--------- Find element by idNot implemented--------- Check various node_name return valuesNot needed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -