012.phpt 7.7 KB

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