123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- --TEST--
- Accessing children nodes
- --EXTENSIONS--
- tidy
- --FILE--
- <?php
- function dump_nodes(tidyNode $node) {
- var_dump($node->hasChildren());
- if($node->hasChildren()) {
- foreach($node->child as $c) {
- var_dump($c);
- if($c->hasChildren()) {
- dump_nodes($c);
- }
- }
- }
- }
- $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>", array('newline' => 'LF'));
- $html = $a->html();
- dump_nodes($html);
- ?>
- --EXPECTF--
- bool(true)
- object(tidyNode)#3 (9) {
- ["value"]=>
- string(31) "<head>
- <title></title>
- </head>
- "
- ["name"]=>
- string(4) "head"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(7)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(46)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#4 (9) {
- ["value"]=>
- string(16) "<title></title>
- "
- ["name"]=>
- string(5) "title"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(87)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(%i)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- bool(true)
- object(tidyNode)#4 (9) {
- ["value"]=>
- string(16) "<title></title>
- "
- ["name"]=>
- string(5) "title"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(87)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(%i)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- object(tidyNode)#5 (9) {
- ["value"]=>
- string(80) "<body bgcolor="#FFFFFF" alink="#000000">
- <b>Hi</b><i>Bye<u>Test</u></i>
- </body>
- "
- ["name"]=>
- string(4) "body"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(7)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(16)
- ["attribute"]=>
- array(2) {
- ["bgcolor"]=>
- string(7) "#FFFFFF"
- ["alink"]=>
- string(7) "#000000"
- }
- ["child"]=>
- array(2) {
- [0]=>
- object(tidyNode)#6 (9) {
- ["value"]=>
- string(9) "<b>Hi</b>"
- ["name"]=>
- string(1) "b"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(43)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(8)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#7 (8) {
- ["value"]=>
- string(2) "Hi"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(46)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- [1]=>
- object(tidyNode)#8 (9) {
- ["value"]=>
- string(21) "<i>Bye<u>Test</u></i>"
- ["name"]=>
- string(1) "i"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(52)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(49)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(2) {
- [0]=>
- object(tidyNode)#9 (8) {
- ["value"]=>
- string(3) "Bye"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(55)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- [1]=>
- object(tidyNode)#10 (9) {
- ["value"]=>
- string(11) "<u>Test</u>"
- ["name"]=>
- string(1) "u"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(58)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(%i)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#11 (8) {
- ["value"]=>
- string(4) "Test"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(61)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- }
- }
- }
- }
- bool(true)
- object(tidyNode)#6 (9) {
- ["value"]=>
- string(9) "<b>Hi</b>"
- ["name"]=>
- string(1) "b"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(43)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(8)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#7 (8) {
- ["value"]=>
- string(2) "Hi"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(46)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- bool(true)
- object(tidyNode)#7 (8) {
- ["value"]=>
- string(2) "Hi"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(46)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- object(tidyNode)#8 (9) {
- ["value"]=>
- string(21) "<i>Bye<u>Test</u></i>"
- ["name"]=>
- string(1) "i"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(52)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(49)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(2) {
- [0]=>
- object(tidyNode)#9 (8) {
- ["value"]=>
- string(3) "Bye"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(55)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- [1]=>
- object(tidyNode)#10 (9) {
- ["value"]=>
- string(11) "<u>Test</u>"
- ["name"]=>
- string(1) "u"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(58)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(%i)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#11 (8) {
- ["value"]=>
- string(4) "Test"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(61)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- }
- }
- bool(true)
- object(tidyNode)#9 (8) {
- ["value"]=>
- string(3) "Bye"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(55)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- object(tidyNode)#10 (9) {
- ["value"]=>
- string(11) "<u>Test</u>"
- ["name"]=>
- string(1) "u"
- ["type"]=>
- int(5)
- ["line"]=>
- int(1)
- ["column"]=>
- int(58)
- ["proprietary"]=>
- bool(false)
- ["id"]=>
- int(%i)
- ["attribute"]=>
- NULL
- ["child"]=>
- array(1) {
- [0]=>
- object(tidyNode)#11 (8) {
- ["value"]=>
- string(4) "Test"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(61)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
- }
- }
- bool(true)
- object(tidyNode)#11 (8) {
- ["value"]=>
- string(4) "Test"
- ["name"]=>
- string(0) ""
- ["type"]=>
- int(4)
- ["line"]=>
- int(1)
- ["column"]=>
- int(61)
- ["proprietary"]=>
- bool(false)
- ["attribute"]=>
- NULL
- ["child"]=>
- NULL
- }
|