Annotation of embedaddon/php/ext/dom/tests/dom001.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test 1: Accessing single node
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: require_once("dom_test.inc");
                      8: 
                      9: echo "Test 1: accessing single nodes from php\n";
                     10: $dom = new domDocument;
                     11: $dom->loadxml($xmlstr);
                     12: if(!$dom) {
                     13:   echo "Error while parsing the document\n";
                     14:   exit;
                     15: }
                     16: 
                     17: // children() of of document would result in a memleak
                     18: //$children = $dom->children();
                     19: //print_node_list($children);
                     20: 
                     21: echo "--------- root\n";
                     22: $rootnode = $dom->documentElement;
                     23: print_node($rootnode);
                     24: 
                     25: echo "--------- children of root\n";
                     26: $children = $rootnode->childNodes;
                     27: print_node_list($children);
                     28: 
                     29: // The last node should be identical with the last entry in the children array
                     30: echo "--------- last\n";
                     31: $last = $rootnode->lastChild;
                     32: print_node($last);
                     33: 
                     34: // The parent of this last node is the root again
                     35: echo "--------- parent\n";
                     36: $parent = $last->parentNode;
                     37: print_node($parent);
                     38: 
                     39: // The children of this parent are the same children as one above
                     40: echo "--------- children of parent\n";
                     41: $children = $parent->childNodes;
                     42: print_node_list($children);
                     43: 
                     44: echo "--------- creating a new attribute\n";
                     45: //This is worthless
                     46: //$attr = $dom->createAttribute("src", "picture.gif");
                     47: //print_r($attr);
                     48: 
                     49: //$rootnode->set_attributeNode($attr); 
                     50: $attr = $rootnode->setAttribute("src", "picture.gif");
                     51: $attr = $rootnode->getAttribute("src");
                     52: print_r($attr);
                     53: print "\n";
                     54: 
                     55: echo "--------- Get Attribute Node\n";
                     56: $attr = $rootnode->getAttributeNode("src");
                     57: print_node($attr);
                     58: 
                     59: echo "--------- Remove Attribute Node\n";
                     60: $attr = $rootnode->removeAttribute("src");
                     61: print "Removed " . $attr . " attributes.\n";
                     62: 
                     63: echo "--------- attributes of rootnode\n";
                     64: $attrs = $rootnode->attributes;
                     65: print_node_list($attrs);
                     66: 
                     67: echo "--------- children of an attribute\n";
                     68: $children = $attrs->item(0)->childNodes;
                     69: print_node_list($children);
                     70: 
                     71: echo "--------- Add child to root\n";
                     72: $myelement = new domElement("Silly", "Symphony");
                     73: $newchild = $rootnode->appendChild($myelement);
                     74: print_node($newchild);
                     75: print $dom->saveXML();
                     76: print "\n";
                     77: 
                     78: echo "--------- Find element by tagname\n";
                     79: echo "    Using dom\n";
                     80: $children = $dom->getElementsByTagname("Silly");
                     81: print_node_list($children);
                     82: 
                     83: echo "    Using elem\n";
                     84: $children = $rootnode->getElementsByTagName("Silly");
                     85: print_node_list($children);
                     86: 
                     87: echo "--------- Unlink Node\n";
                     88: print_node($children->item(0));
                     89: $rootnode->removeChild($children->item(0));
                     90: print_node_list($rootnode->childNodes);
                     91: print $dom->savexml();
                     92: 
                     93: echo "--------- Find element by id\n";
                     94: print ("Not implemented\n");
                     95: 
                     96: echo "--------- Check various node_name return values\n";
                     97: print ("Not needed\n");
                     98: 
                     99: ?>
                    100: --EXPECT--
                    101: Test 1: accessing single nodes from php
                    102: --------- root
                    103: Node Name: chapter
                    104: Node Type: 1
                    105: Num Children: 4
                    106: 
                    107: --------- children of root
                    108: Node Name: title
                    109: Node Type: 1
                    110: Num Children: 1
                    111: Node Content: Title
                    112: 
                    113: Node Name: #text
                    114: Node Type: 3
                    115: Num Children: 0
                    116: Node Content: 
                    117: 
                    118: 
                    119: Node Name: para
                    120: Node Type: 1
                    121: Num Children: 7
                    122: 
                    123: Node Name: #text
                    124: Node Type: 3
                    125: Num Children: 0
                    126: Node Content: 
                    127: 
                    128: 
                    129: --------- last
                    130: Node Name: #text
                    131: Node Type: 3
                    132: Num Children: 0
                    133: Node Content: 
                    134: 
                    135: 
                    136: --------- parent
                    137: Node Name: chapter
                    138: Node Type: 1
                    139: Num Children: 4
                    140: 
                    141: --------- children of parent
                    142: Node Name: title
                    143: Node Type: 1
                    144: Num Children: 1
                    145: Node Content: Title
                    146: 
                    147: Node Name: #text
                    148: Node Type: 3
                    149: Num Children: 0
                    150: Node Content: 
                    151: 
                    152: 
                    153: Node Name: para
                    154: Node Type: 1
                    155: Num Children: 7
                    156: 
                    157: Node Name: #text
                    158: Node Type: 3
                    159: Num Children: 0
                    160: Node Content: 
                    161: 
                    162: 
                    163: --------- creating a new attribute
                    164: picture.gif
                    165: --------- Get Attribute Node
                    166: Node Name: src
                    167: Node Type: 2
                    168: Num Children: 1
                    169: Node Content: picture.gif
                    170: 
                    171: --------- Remove Attribute Node
                    172: Removed 1 attributes.
                    173: --------- attributes of rootnode
                    174: Node Name: language
                    175: Node Type: 2
                    176: Num Children: 1
                    177: Node Content: en
                    178: 
                    179: --------- children of an attribute
                    180: Node Name: #text
                    181: Node Type: 3
                    182: Num Children: 0
                    183: Node Content: en
                    184: 
                    185: --------- Add child to root
                    186: Node Name: Silly
                    187: Node Type: 1
                    188: Num Children: 1
                    189: Node Content: Symphony
                    190: 
                    191: <?xml version="1.0" standalone="yes"?>
                    192: <!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
                    193: <!ENTITY sp "spanish">
                    194: ]>
                    195: <!-- lsfj  -->
                    196: <chapter language="en"><title language="en">Title</title>
                    197: <para language="ge">
                    198: &sp;
                    199: <!-- comment -->
                    200: <informaltable language="&sp;kkk">
                    201: <tgroup cols="3">
                    202: <tbody>
                    203: <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
                    204: <row><entry>a2</entry><entry>c2</entry></row>
                    205: <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
                    206: </tbody>
                    207: </tgroup>
                    208: </informaltable>
                    209: </para>
                    210: <Silly>Symphony</Silly></chapter>
                    211: 
                    212: --------- Find element by tagname
                    213:     Using dom
                    214: Node Name: Silly
                    215: Node Type: 1
                    216: Num Children: 1
                    217: Node Content: Symphony
                    218: 
                    219:     Using elem
                    220: Node Name: Silly
                    221: Node Type: 1
                    222: Num Children: 1
                    223: Node Content: Symphony
                    224: 
                    225: --------- Unlink Node
                    226: Node Name: Silly
                    227: Node Type: 1
                    228: Num Children: 1
                    229: Node Content: Symphony
                    230: 
                    231: Node Name: title
                    232: Node Type: 1
                    233: Num Children: 1
                    234: Node Content: Title
                    235: 
                    236: Node Name: #text
                    237: Node Type: 3
                    238: Num Children: 0
                    239: Node Content: 
                    240: 
                    241: 
                    242: Node Name: para
                    243: Node Type: 1
                    244: Num Children: 7
                    245: 
                    246: Node Name: #text
                    247: Node Type: 3
                    248: Num Children: 0
                    249: Node Content: 
                    250: 
                    251: 
                    252: <?xml version="1.0" standalone="yes"?>
                    253: <!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
                    254: <!ENTITY sp "spanish">
                    255: ]>
                    256: <!-- lsfj  -->
                    257: <chapter language="en"><title language="en">Title</title>
                    258: <para language="ge">
                    259: &sp;
                    260: <!-- comment -->
                    261: <informaltable language="&sp;kkk">
                    262: <tgroup cols="3">
                    263: <tbody>
                    264: <row><entry>a1</entry><entry morerows="1">b1</entry><entry>c1</entry></row>
                    265: <row><entry>a2</entry><entry>c2</entry></row>
                    266: <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
                    267: </tbody>
                    268: </tgroup>
                    269: </informaltable>
                    270: </para>
                    271: </chapter>
                    272: --------- Find element by id
                    273: Not implemented
                    274: --------- Check various node_name return values
                    275: Not needed

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>