xref: /PHP-7.2/ext/dom/examples/dom1.inc (revision 6ac34646)
1<?PHP
2$xmlstr = "<?xml version='1.0' standalone='yes'?>
3<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'
4[ <!ENTITY sp \"spanish\">
5]>
6<!-- lsfj  -->
7<chapter language='en'><title language='en'>Title</title>
8<para language='ge'>
9&sp;
10<!-- comment -->
11<informaltable language='&sp;kkk'>
12<tgroup cols='3'>
13<tbody>
14<row><entry>a1</entry><entry morerows='1'>b1</entry><entry>c1</entry></row>
15<row><entry>a2</entry><entry>c2</entry></row>
16<row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row>
17</tbody>
18</tgroup>
19</informaltable>
20</para>
21</chapter> ";
22
23function print_node($node)
24{
25  print "Node Name: " . $node->nodeName;
26  print "\nNode Type: " . $node->nodeType;
27  $child_count = $node->childNodes->length;
28  print "\nNum Children: " . $child_count;
29  if($child_count <= 1){
30    print "\nNode Content: " . $node->nodeValue;
31  }
32  print "\n\n";
33}
34
35function print_node_list($nodelist)
36{
37  foreach($nodelist as $node)
38  {
39    print_node($node);
40  }
41}
42
43?>
44