xref: /PHP-8.3/ext/tidy/tests/012.phpt (revision aeb4acac)
1--TEST--
2Accessing children nodes
3--EXTENSIONS--
4tidy
5--FILE--
6<?php
7
8        function dump_nodes(tidyNode $node) {
9
10            var_dump($node->hasChildren());
11            if($node->hasChildren()) {
12
13                foreach($node->child as $c) {
14
15                    var_dump($c);
16
17                    if($c->hasChildren()) {
18
19                        dump_nodes($c);
20
21                    }
22                }
23
24            }
25
26        }
27
28        $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>", array('newline' => 'LF'));
29        $html = $a->html();
30        dump_nodes($html);
31
32?>
33--EXPECTF--
34bool(true)
35object(tidyNode)#3 (9) {
36  ["value"]=>
37  string(31) "<head>
38<title></title>
39</head>
40"
41  ["name"]=>
42  string(4) "head"
43  ["type"]=>
44  int(5)
45  ["line"]=>
46  int(1)
47  ["column"]=>
48  int(7)
49  ["proprietary"]=>
50  bool(false)
51  ["id"]=>
52  int(46)
53  ["attribute"]=>
54  NULL
55  ["child"]=>
56  array(1) {
57    [0]=>
58    object(tidyNode)#4 (9) {
59      ["value"]=>
60      string(16) "<title></title>
61"
62      ["name"]=>
63      string(5) "title"
64      ["type"]=>
65      int(5)
66      ["line"]=>
67      int(1)
68      ["column"]=>
69      int(87)
70      ["proprietary"]=>
71      bool(false)
72      ["id"]=>
73      int(%i)
74      ["attribute"]=>
75      NULL
76      ["child"]=>
77      NULL
78    }
79  }
80}
81bool(true)
82object(tidyNode)#4 (9) {
83  ["value"]=>
84  string(16) "<title></title>
85"
86  ["name"]=>
87  string(5) "title"
88  ["type"]=>
89  int(5)
90  ["line"]=>
91  int(1)
92  ["column"]=>
93  int(87)
94  ["proprietary"]=>
95  bool(false)
96  ["id"]=>
97  int(%i)
98  ["attribute"]=>
99  NULL
100  ["child"]=>
101  NULL
102}
103object(tidyNode)#5 (9) {
104  ["value"]=>
105  string(80) "<body bgcolor="#FFFFFF" alink="#000000">
106<b>Hi</b><i>Bye<u>Test</u></i>
107</body>
108"
109  ["name"]=>
110  string(4) "body"
111  ["type"]=>
112  int(5)
113  ["line"]=>
114  int(1)
115  ["column"]=>
116  int(7)
117  ["proprietary"]=>
118  bool(false)
119  ["id"]=>
120  int(16)
121  ["attribute"]=>
122  array(2) {
123    ["bgcolor"]=>
124    string(7) "#FFFFFF"
125    ["alink"]=>
126    string(7) "#000000"
127  }
128  ["child"]=>
129  array(2) {
130    [0]=>
131    object(tidyNode)#6 (9) {
132      ["value"]=>
133      string(9) "<b>Hi</b>"
134      ["name"]=>
135      string(1) "b"
136      ["type"]=>
137      int(5)
138      ["line"]=>
139      int(1)
140      ["column"]=>
141      int(43)
142      ["proprietary"]=>
143      bool(false)
144      ["id"]=>
145      int(8)
146      ["attribute"]=>
147      NULL
148      ["child"]=>
149      array(1) {
150        [0]=>
151        object(tidyNode)#7 (9) {
152          ["value"]=>
153          string(2) "Hi"
154          ["name"]=>
155          string(0) ""
156          ["type"]=>
157          int(4)
158          ["line"]=>
159          int(1)
160          ["column"]=>
161          int(46)
162          ["proprietary"]=>
163          bool(false)
164          ["id"]=>
165          NULL
166          ["attribute"]=>
167          NULL
168          ["child"]=>
169          NULL
170        }
171      }
172    }
173    [1]=>
174    object(tidyNode)#8 (9) {
175      ["value"]=>
176      string(21) "<i>Bye<u>Test</u></i>"
177      ["name"]=>
178      string(1) "i"
179      ["type"]=>
180      int(5)
181      ["line"]=>
182      int(1)
183      ["column"]=>
184      int(52)
185      ["proprietary"]=>
186      bool(false)
187      ["id"]=>
188      int(49)
189      ["attribute"]=>
190      NULL
191      ["child"]=>
192      array(2) {
193        [0]=>
194        object(tidyNode)#9 (9) {
195          ["value"]=>
196          string(3) "Bye"
197          ["name"]=>
198          string(0) ""
199          ["type"]=>
200          int(4)
201          ["line"]=>
202          int(1)
203          ["column"]=>
204          int(55)
205          ["proprietary"]=>
206          bool(false)
207          ["id"]=>
208          NULL
209          ["attribute"]=>
210          NULL
211          ["child"]=>
212          NULL
213        }
214        [1]=>
215        object(tidyNode)#10 (9) {
216          ["value"]=>
217          string(11) "<u>Test</u>"
218          ["name"]=>
219          string(1) "u"
220          ["type"]=>
221          int(5)
222          ["line"]=>
223          int(1)
224          ["column"]=>
225          int(58)
226          ["proprietary"]=>
227          bool(false)
228          ["id"]=>
229          int(%i)
230          ["attribute"]=>
231          NULL
232          ["child"]=>
233          array(1) {
234            [0]=>
235            object(tidyNode)#11 (9) {
236              ["value"]=>
237              string(4) "Test"
238              ["name"]=>
239              string(0) ""
240              ["type"]=>
241              int(4)
242              ["line"]=>
243              int(1)
244              ["column"]=>
245              int(61)
246              ["proprietary"]=>
247              bool(false)
248              ["id"]=>
249              NULL
250              ["attribute"]=>
251              NULL
252              ["child"]=>
253              NULL
254            }
255          }
256        }
257      }
258    }
259  }
260}
261bool(true)
262object(tidyNode)#6 (9) {
263  ["value"]=>
264  string(9) "<b>Hi</b>"
265  ["name"]=>
266  string(1) "b"
267  ["type"]=>
268  int(5)
269  ["line"]=>
270  int(1)
271  ["column"]=>
272  int(43)
273  ["proprietary"]=>
274  bool(false)
275  ["id"]=>
276  int(8)
277  ["attribute"]=>
278  NULL
279  ["child"]=>
280  array(1) {
281    [0]=>
282    object(tidyNode)#7 (9) {
283      ["value"]=>
284      string(2) "Hi"
285      ["name"]=>
286      string(0) ""
287      ["type"]=>
288      int(4)
289      ["line"]=>
290      int(1)
291      ["column"]=>
292      int(46)
293      ["proprietary"]=>
294      bool(false)
295      ["id"]=>
296      NULL
297      ["attribute"]=>
298      NULL
299      ["child"]=>
300      NULL
301    }
302  }
303}
304bool(true)
305object(tidyNode)#7 (9) {
306  ["value"]=>
307  string(2) "Hi"
308  ["name"]=>
309  string(0) ""
310  ["type"]=>
311  int(4)
312  ["line"]=>
313  int(1)
314  ["column"]=>
315  int(46)
316  ["proprietary"]=>
317  bool(false)
318  ["id"]=>
319  NULL
320  ["attribute"]=>
321  NULL
322  ["child"]=>
323  NULL
324}
325object(tidyNode)#8 (9) {
326  ["value"]=>
327  string(21) "<i>Bye<u>Test</u></i>"
328  ["name"]=>
329  string(1) "i"
330  ["type"]=>
331  int(5)
332  ["line"]=>
333  int(1)
334  ["column"]=>
335  int(52)
336  ["proprietary"]=>
337  bool(false)
338  ["id"]=>
339  int(49)
340  ["attribute"]=>
341  NULL
342  ["child"]=>
343  array(2) {
344    [0]=>
345    object(tidyNode)#9 (9) {
346      ["value"]=>
347      string(3) "Bye"
348      ["name"]=>
349      string(0) ""
350      ["type"]=>
351      int(4)
352      ["line"]=>
353      int(1)
354      ["column"]=>
355      int(55)
356      ["proprietary"]=>
357      bool(false)
358      ["id"]=>
359      NULL
360      ["attribute"]=>
361      NULL
362      ["child"]=>
363      NULL
364    }
365    [1]=>
366    object(tidyNode)#10 (9) {
367      ["value"]=>
368      string(11) "<u>Test</u>"
369      ["name"]=>
370      string(1) "u"
371      ["type"]=>
372      int(5)
373      ["line"]=>
374      int(1)
375      ["column"]=>
376      int(58)
377      ["proprietary"]=>
378      bool(false)
379      ["id"]=>
380      int(%i)
381      ["attribute"]=>
382      NULL
383      ["child"]=>
384      array(1) {
385        [0]=>
386        object(tidyNode)#11 (9) {
387          ["value"]=>
388          string(4) "Test"
389          ["name"]=>
390          string(0) ""
391          ["type"]=>
392          int(4)
393          ["line"]=>
394          int(1)
395          ["column"]=>
396          int(61)
397          ["proprietary"]=>
398          bool(false)
399          ["id"]=>
400          NULL
401          ["attribute"]=>
402          NULL
403          ["child"]=>
404          NULL
405        }
406      }
407    }
408  }
409}
410bool(true)
411object(tidyNode)#9 (9) {
412  ["value"]=>
413  string(3) "Bye"
414  ["name"]=>
415  string(0) ""
416  ["type"]=>
417  int(4)
418  ["line"]=>
419  int(1)
420  ["column"]=>
421  int(55)
422  ["proprietary"]=>
423  bool(false)
424  ["id"]=>
425  NULL
426  ["attribute"]=>
427  NULL
428  ["child"]=>
429  NULL
430}
431object(tidyNode)#10 (9) {
432  ["value"]=>
433  string(11) "<u>Test</u>"
434  ["name"]=>
435  string(1) "u"
436  ["type"]=>
437  int(5)
438  ["line"]=>
439  int(1)
440  ["column"]=>
441  int(58)
442  ["proprietary"]=>
443  bool(false)
444  ["id"]=>
445  int(%i)
446  ["attribute"]=>
447  NULL
448  ["child"]=>
449  array(1) {
450    [0]=>
451    object(tidyNode)#11 (9) {
452      ["value"]=>
453      string(4) "Test"
454      ["name"]=>
455      string(0) ""
456      ["type"]=>
457      int(4)
458      ["line"]=>
459      int(1)
460      ["column"]=>
461      int(61)
462      ["proprietary"]=>
463      bool(false)
464      ["id"]=>
465      NULL
466      ["attribute"]=>
467      NULL
468      ["child"]=>
469      NULL
470    }
471  }
472}
473bool(true)
474object(tidyNode)#11 (9) {
475  ["value"]=>
476  string(4) "Test"
477  ["name"]=>
478  string(0) ""
479  ["type"]=>
480  int(4)
481  ["line"]=>
482  int(1)
483  ["column"]=>
484  int(61)
485  ["proprietary"]=>
486  bool(false)
487  ["id"]=>
488  NULL
489  ["attribute"]=>
490  NULL
491  ["child"]=>
492  NULL
493}
494