46bb153efe35e87f389cf206fed0117ca5ff69bc.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <?php
  2. // -----------------------------------------------------------------------------
  3. // setup
  4. error_reporting(E_ALL);
  5. require_once('../simple_html_dom.php');
  6. $dom = new simple_html_dom;
  7. // -----------------------------------------------------------------------------
  8. //self-closing tags test
  9. $str = <<<HTML
  10. <hr>
  11. HTML;
  12. $dom->load($str);
  13. $e = $dom->find('hr', 0);
  14. $e->id= 'foo';
  15. assert($e->outertext=='<hr id="foo">');
  16. // -----------------------------------------------
  17. $str = <<<HTML
  18. <hr/>
  19. HTML;
  20. $dom->load($str);
  21. $e = $dom->find('hr', 0);
  22. $e->id= 'foo';
  23. assert($e->outertext=='<hr id="foo"/>');
  24. // -----------------------------------------------
  25. $str = <<<HTML
  26. <hr />
  27. HTML;
  28. $dom->load($str);
  29. $e = $dom->find('hr', 0);
  30. $e->id= 'foo';
  31. assert($e->outertext=='<hr id="foo" />');
  32. // -----------------------------------------------
  33. $str = <<<HTML
  34. <hr>
  35. HTML;
  36. $dom->load($str);
  37. $e = $dom->find('hr', 0);
  38. $e->id= 'foo';
  39. $e->class = 'bar';
  40. assert($e->outertext=='<hr id="foo" class="bar">');
  41. // -----------------------------------------------
  42. $str = <<<HTML
  43. <hr/>
  44. HTML;
  45. $dom->load($str);
  46. $e = $dom->find('hr', 0);
  47. $e->id= 'foo';
  48. $e->class = 'bar';
  49. assert($e->outertext=='<hr id="foo" class="bar"/>');
  50. // -----------------------------------------------
  51. $str = <<<HTML
  52. <hr />
  53. HTML;
  54. $dom->load($str);
  55. $e = $dom->find('hr', 0);
  56. $e->id= 'foo';
  57. $e->class = 'bar';
  58. assert($e->outertext=='<hr id="foo" class="bar" />');
  59. // -----------------------------------------------
  60. $str = <<<HTML
  61. <hr id="foo" kk=ll>
  62. HTML;
  63. $dom->load($str);
  64. $e = $dom->find('hr', 0);
  65. $e->class = 'bar';
  66. assert($e->outertext=='<hr id="foo" kk=ll class="bar">');
  67. // -----------------------------------------------
  68. $str = <<<HTML
  69. <hr id="foo" kk="ll"/>
  70. HTML;
  71. $dom->load($str);
  72. $e = $dom->find('hr', 0);
  73. $e->class = 'bar';
  74. assert($e->outertext=='<hr id="foo" kk="ll" class="bar"/>');
  75. // -----------------------------------------------
  76. $str = <<<HTML
  77. <hr id="foo" kk=ll />
  78. HTML;
  79. $dom->load($str);
  80. $e = $dom->find('hr', 0);
  81. $e->class = 'bar';
  82. assert($e->outertext=='<hr id="foo" kk=ll class="bar" />');
  83. // -----------------------------------------------
  84. $str = <<<HTML
  85. <div><nobr></div>
  86. HTML;
  87. $dom->load($str);
  88. $e = $dom->find('nobr', 0);
  89. assert($e->outertext=='<nobr>');
  90. // -----------------------------------------------------------------------------
  91. // optional closing tags test
  92. $str = <<<HTML
  93. <body>
  94. </b><.b></a>
  95. </body>
  96. HTML;
  97. $dom = str_get_html($str);
  98. assert($dom->find('body', 0)->outertext==$str);
  99. // -----------------------------------------------
  100. $str = <<<HTML
  101. <html>
  102. <body>
  103. <a>foo</a>
  104. <a>foo2</a>
  105. HTML;
  106. $dom = str_get_html($str);
  107. assert($dom==$str);
  108. assert($dom->find('html body a', 1)->innertext=='foo2');
  109. // -----------------------------------------------
  110. $str = <<<HTML
  111. HTML;
  112. $dom = str_get_html($str);
  113. assert($dom==$str);
  114. assert($dom->find('html a', 1)===null);
  115. //assert($dom->find('html a', 1)->innertext=='foo2');
  116. // -----------------------------------------------
  117. $str = <<<HTML
  118. <body>
  119. <div>
  120. </body>
  121. HTML;
  122. $dom = str_get_html($str);
  123. assert($dom==$str);
  124. assert($dom->find('body', 0)->outertext==$str);
  125. // -----------------------------------------------
  126. $str = <<<HTML
  127. <body>
  128. <div> </a> </div>
  129. </body>
  130. HTML;
  131. $dom = str_get_html($str);
  132. assert($dom->find('body', 0)->outertext==$str);
  133. // -----------------------------------------------
  134. $str = <<<HTML
  135. <table>
  136. <tr>
  137. <td><b>aa</b>
  138. <tr>
  139. <td><b>bb</b>
  140. </table>
  141. HTML;
  142. $dom = str_get_html($str);
  143. assert($dom==$str);
  144. // -----------------------------------------------
  145. $str = <<<HTML
  146. <table>
  147. <tr><td>1<td>2<td>3
  148. </table>
  149. HTML;
  150. $dom = str_get_html($str);
  151. assert(count($dom->find('td'))==3);
  152. assert($dom->find('td', 0)->innertext=='1');
  153. assert($dom->find('td', 0)->outertext=='<td>1');
  154. assert($dom->find('td', 1)->innertext=='2');
  155. assert($dom->find('td', 1)->outertext=='<td>2');
  156. assert($dom->find('td', 2)->innertext=="3\r\n");
  157. assert($dom->find('td', 2)->outertext=="<td>3\r\n");
  158. // -----------------------------------------------
  159. $str = <<<HTML
  160. <table>
  161. <tr>
  162. <td><b>1</b></td>
  163. <td><b>2</b></td>
  164. <td><b>3</b></td>
  165. </table>
  166. HTML;
  167. $dom = str_get_html($str);
  168. assert(count($dom->find('tr td'))==3);
  169. // -----------------------------------------------
  170. $str = <<<HTML
  171. <table>
  172. <tr><td><b>11</b></td><td><b>12</b></td><td><b>13</b></td>
  173. <tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>
  174. </table>
  175. HTML;
  176. $dom = str_get_html($str);
  177. assert(count($dom->find('tr'))==2);
  178. assert(count($dom->find('tr td'))==6);
  179. assert($dom->find('tr', 1)->outertext=="<tr><td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
  180. assert($dom->find('tr', 1)->innertext=="<td><b>21</b></td><td><b>32</b></td><td><b>43</b></td>\r\n");
  181. assert($dom->find('tr', 1)->plaintext=="213243\r\n");
  182. // -----------------------------------------------
  183. $str = <<<HTML
  184. <p>1
  185. <p>2</p>
  186. <p>3
  187. HTML;
  188. $dom = str_get_html($str);
  189. assert(count($dom->find('p'))==3);
  190. assert($dom->find('p', 0)->innertext=="1\r\n");
  191. assert($dom->find('p', 0)->outertext=="<p>1\r\n");
  192. assert($dom->find('p', 1)->innertext=="2");
  193. assert($dom->find('p', 1)->outertext=="<p>2</p>");
  194. assert($dom->find('p', 2)->innertext=="3");
  195. assert($dom->find('p', 2)->outertext=="<p>3");
  196. // -----------------------------------------------
  197. $str = <<<HTML
  198. <nobr>1
  199. <nobr>2</nobr>
  200. <nobr>3
  201. HTML;
  202. $dom = str_get_html($str);
  203. assert(count($dom->find('nobr'))==3);
  204. assert($dom->find('nobr', 0)->innertext=="1\r\n");
  205. assert($dom->find('nobr', 0)->outertext=="<nobr>1\r\n");
  206. assert($dom->find('nobr', 1)->innertext=="2");
  207. assert($dom->find('nobr', 1)->outertext=="<nobr>2</nobr>");
  208. assert($dom->find('nobr', 2)->innertext=="3");
  209. assert($dom->find('nobr', 2)->outertext=="<nobr>3");
  210. // -----------------------------------------------
  211. $str = <<<HTML
  212. <dl><dt>1<dd>2<dt>3<dd>4</dl>
  213. HTML;
  214. $dom = str_get_html($str);
  215. assert(count($dom->find('dt'))==2);
  216. assert(count($dom->find('dd'))==2);
  217. assert($dom->find('dt', 0)->innertext=="1");
  218. assert($dom->find('dt', 0)->outertext=="<dt>1");
  219. assert($dom->find('dt', 1)->innertext=="3");
  220. assert($dom->find('dt', 1)->outertext=="<dt>3");
  221. assert($dom->find('dd', 0)->innertext=="2");
  222. assert($dom->find('dd', 0)->outertext=="<dd>2");
  223. assert($dom->find('dd', 1)->innertext=="4");
  224. assert($dom->find('dd', 1)->outertext=="<dd>4");
  225. // -----------------------------------------------
  226. $str = <<<HTML
  227. <dl id="dl1"><dt>11<dd>12<dt>13<dd>14</dl>
  228. <dl id="dl2"><dt>21<dd>22<dt>23<dd>24</dl>
  229. HTML;
  230. $dom = str_get_html($str);
  231. assert(count($dom->find('#dl1 dt'))==2);
  232. assert(count($dom->find('#dl2 dd'))==2);
  233. assert($dom->find('dl', 0)->innertext=="<dt>11<dd>12<dt>13<dd>14");
  234. assert($dom->find('dl', 1)->innertext=="<dt>21<dd>22<dt>23<dd>24");
  235. // -----------------------------------------------
  236. $str = <<<HTML
  237. <ul id="ul1"><li><b>1</b><li><b>2</b></ul>
  238. <ul id="ul2"><li><b>3</b><li><b>4</b></ul>
  239. HTML;
  240. $dom = str_get_html($str);
  241. assert(count($dom->find('ul[id=ul1] li'))==2);
  242. // -----------------------------------------------------------------------------
  243. // invalid test
  244. $str = <<<HTML
  245. <div>
  246. <div class="class0" id="id0" >
  247. <img class="class0" id="id0" src="src0">
  248. </img>
  249. <img class="class0" id="id0" src="src0">
  250. </div>
  251. </div>
  252. HTML;
  253. $dom->load($str);
  254. assert(count($dom->find('img'))==2);
  255. assert(count($dom->find('img'))==2);
  256. assert($dom==$str);
  257. // -----------------------------------------------
  258. $str = <<<HTML
  259. <div>
  260. <div class="class0" id="id0" >
  261. <span></span>
  262. </span>
  263. <span></span>
  264. </div>
  265. </div>
  266. HTML;
  267. $dom->load($str);
  268. assert(count($dom->find('span'))==2);
  269. assert(count($dom->find('div'))==2);
  270. assert($dom==$str);
  271. // -----------------------------------------------
  272. $str = <<<HTML
  273. <div>
  274. <div class="class0" id="id0" >
  275. <span></span>
  276. <span>
  277. <span></span>
  278. </div>
  279. </div>
  280. HTML;
  281. $dom->load($str);
  282. assert(count($dom->find('span'))==3);
  283. assert(count($dom->find('div'))==2);
  284. assert($dom==$str);
  285. // -----------------------------------------------
  286. $str = <<<HTML
  287. <ul class="menublock">
  288. </li>
  289. <ul>
  290. <li>
  291. <a href="http://www.cyberciti.biz/tips/pollsarchive">Polls Archive</a>
  292. </li>
  293. </ul>
  294. </li>
  295. </ul>
  296. HTML;
  297. $dom->load($str);
  298. assert(count($dom->find('ul'))==2);
  299. assert(count($dom->find('ul ul'))==1);
  300. assert(count($dom->find('li'))==1);
  301. assert(count($dom->find('a'))==1);
  302. assert($dom==$str);
  303. // -----------------------------------------------
  304. $str = <<<HTML
  305. <td>
  306. <div>
  307. </span>
  308. </div>
  309. </td>
  310. HTML;
  311. $dom->load($str);
  312. assert(count($dom->find('td'))==1);
  313. assert(count($dom->find('div'))==1);
  314. assert(count($dom->find('td div'))==1);
  315. assert($dom==$str);
  316. // -----------------------------------------------
  317. $str = <<<HTML
  318. <td>
  319. <div>
  320. </b>
  321. </div>
  322. </td>
  323. HTML;
  324. $dom->load($str);
  325. assert(count($dom->find('td'))==1);
  326. assert(count($dom->find('div'))==1);
  327. assert(count($dom->find('td div'))==1);
  328. assert($dom==$str);
  329. // -----------------------------------------------
  330. $str = <<<HTML
  331. <td>
  332. <div></div>
  333. </div>
  334. </td>
  335. HTML;
  336. $dom->load($str);
  337. assert(count($dom->find('td'))==1);
  338. assert(count($dom->find('div'))==1);
  339. assert(count($dom->find('td div'))==1);
  340. assert($dom==$str);
  341. // -----------------------------------------------
  342. $str = <<<HTML
  343. <html>
  344. <body>
  345. <table>
  346. <tr>
  347. foo</span>
  348. <span>bar</span>
  349. </span>important
  350. </tr>
  351. </table>
  352. </bod>
  353. </html>
  354. HTML;
  355. $dom->load($str);
  356. assert(count($dom->find('table span'))===1);
  357. assert($dom->find('table span', 0)->innertext==='bar');
  358. assert($dom==$str);
  359. // -----------------------------------------------
  360. $str = <<<HTML
  361. <td>
  362. <div>
  363. <font>
  364. <b>foo</b>
  365. </div>
  366. </td>
  367. HTML;
  368. $dom->load($str);
  369. assert(count($dom->find('td div font b'))==1);
  370. assert($dom==$str);
  371. // -----------------------------------------------
  372. $str = <<<HTML
  373. <span style="okokok">
  374. ... then slow into 287
  375. <i>
  376. <b>
  377. <font color="#0000CC">(hanover0...more volume between 202 & 53
  378. <i>
  379. <b>
  380. <font color="#0000CC">(parsippany)</font>
  381. </b>
  382. </i>
  383. ...then sluggish in spots out to dover chester road
  384. <i>
  385. <b>
  386. <font color="#0000CC">(randolph)</font>
  387. </b>
  388. </i>..then traffic light delays out to route 46
  389. <i>
  390. <b>
  391. <font color="#0000CC">(roxbury)</font>
  392. </b>
  393. </i>/eb slow into 202
  394. <i>
  395. <b>
  396. <font color="#0000CC">(morris plains)</font>
  397. </b>
  398. </i> & again into 287
  399. <i>
  400. <b>
  401. <font color="#0000CC">(hanover)</font>
  402. </b>
  403. </i>
  404. </span>.
  405. <td class="d N4 c">52</td>
  406. HTML;
  407. $dom->load($str);
  408. assert(count($dom->find('span td'))==0);
  409. assert($dom==$str);
  410. // -----------------------------------------------------------------------------
  411. // invalid '<'
  412. // -----------------------------------------------
  413. $str = <<<HTML
  414. <td><b>test :</b>1 gram but <5 grams</td>
  415. HTML;
  416. $dom->load($str);
  417. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but <5 grams');
  418. assert($dom->find('td', 0)->plaintext==='test :1 gram but <5 grams');
  419. assert($dom==$str);
  420. $str = <<<HTML
  421. <td><b>test :</b>1 gram but<5 grams</td>
  422. HTML;
  423. $dom->load($str);
  424. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but<5 grams');
  425. assert($dom->find('td', 0)->plaintext==='test :1 gram but<5 grams');
  426. assert($dom==$str);
  427. $str = <<<HTML
  428. <td><b>test :</b>1 gram but< 5 grams</td>
  429. HTML;
  430. $dom->load($str);
  431. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but< 5 grams');
  432. assert($dom->find('td', 0)->plaintext==='test :1 gram but< 5 grams');
  433. assert($dom==$str);
  434. $str = <<<HTML
  435. <td><b>test :</b>1 gram but < 5 grams</td>
  436. HTML;
  437. $dom->load($str);
  438. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but < 5 grams');
  439. assert($dom->find('td', 0)->plaintext==='test :1 gram but < 5 grams');
  440. assert($dom==$str);
  441. $str = <<<HTML
  442. <td><b>test :</b>1 gram but 5< grams</td>
  443. HTML;
  444. $dom->load($str);
  445. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
  446. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
  447. assert($dom==$str);
  448. $str = <<<HTML
  449. <td><b>test :</b>1 gram but 5 < grams</td>
  450. HTML;
  451. $dom->load($str);
  452. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 < grams');
  453. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 < grams');
  454. assert($dom==$str);
  455. $str = <<<HTML
  456. <td><b>test :</b>1 gram but 5 <grams</td>
  457. HTML;
  458. $dom->load($str);
  459. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
  460. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
  461. assert($dom==$str);
  462. // -----------------------------------------------
  463. $str = <<<HTML
  464. <td><b>test :</b>1 gram but 5< grams</td>
  465. HTML;
  466. $dom->load($str);
  467. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5< grams');
  468. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5< grams');
  469. assert($dom==$str);
  470. $str = <<<HTML
  471. <td><b>test :</b>1 gram but5< grams</td>
  472. HTML;
  473. $dom->load($str);
  474. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5< grams');
  475. assert($dom->find('td', 0)->plaintext==='test :1 gram but5< grams');
  476. assert($dom==$str);
  477. $str = <<<HTML
  478. <td><b>test :</b>1 gram but 5 <grams</td>
  479. HTML;
  480. $dom->load($str);
  481. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
  482. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
  483. assert($dom==$str);
  484. $str = <<<HTML
  485. <td><b>test :</b>1 gram but 5<grams</td>
  486. HTML;
  487. $dom->load($str);
  488. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5<grams');
  489. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5<grams');
  490. assert($dom==$str);
  491. $str = <<<HTML
  492. <td><b>test :</b>1 gram but 5 <grams</td>
  493. HTML;
  494. $dom->load($str);
  495. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 <grams');
  496. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 <grams');
  497. assert($dom==$str);
  498. // -----------------------------------------------------------------------------
  499. // invalid '>'
  500. // -----------------------------------------------
  501. $str = <<<HTML
  502. <td><b>test :</b>1 gram but >5 grams</td>
  503. HTML;
  504. $dom->load($str);
  505. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but >5 grams');
  506. assert($dom->find('td', 0)->plaintext==='test :1 gram but >5 grams');
  507. assert($dom==$str);
  508. $str = <<<HTML
  509. <td><b>test :</b>1 gram but>5 grams</td>
  510. HTML;
  511. $dom->load($str);
  512. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but>5 grams');
  513. assert($dom->find('td', 0)->plaintext==='test :1 gram but>5 grams');
  514. assert($dom==$str);
  515. $str = <<<HTML
  516. <td><b>test :</b>1 gram but> 5 grams</td>
  517. HTML;
  518. $dom->load($str);
  519. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but> 5 grams');
  520. assert($dom->find('td', 0)->plaintext==='test :1 gram but> 5 grams');
  521. assert($dom==$str);
  522. $str = <<<HTML
  523. <td><b>test :</b>1 gram but > 5 grams</td>
  524. HTML;
  525. $dom->load($str);
  526. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but > 5 grams');
  527. assert($dom->find('td', 0)->plaintext==='test :1 gram but > 5 grams');
  528. assert($dom==$str);
  529. $str = <<<HTML
  530. <td><b>test :</b>1 gram but 5> grams</td>
  531. HTML;
  532. $dom->load($str);
  533. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
  534. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
  535. assert($dom==$str);
  536. $str = <<<HTML
  537. <td><b>test :</b>1 gram but 5 > grams</td>
  538. HTML;
  539. $dom->load($str);
  540. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 > grams');
  541. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 > grams');
  542. assert($dom==$str);
  543. $str = <<<HTML
  544. <td><b>test :</b>1 gram but 5 >grams</td>
  545. HTML;
  546. $dom->load($str);
  547. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
  548. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
  549. assert($dom==$str);
  550. // -----------------------------------------------
  551. $str = <<<HTML
  552. <td><b>test :</b>1 gram but 5> grams</td>
  553. HTML;
  554. $dom->load($str);
  555. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5> grams');
  556. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5> grams');
  557. assert($dom==$str);
  558. $str = <<<HTML
  559. <td><b>test :</b>1 gram but5> grams</td>
  560. HTML;
  561. $dom->load($str);
  562. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but5> grams');
  563. assert($dom->find('td', 0)->plaintext==='test :1 gram but5> grams');
  564. assert($dom==$str);
  565. $str = <<<HTML
  566. <td><b>test :</b>1 gram but 5 >grams</td>
  567. HTML;
  568. $dom->load($str);
  569. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
  570. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
  571. assert($dom==$str);
  572. $str = <<<HTML
  573. <td><b>test :</b>1 gram but 5>grams</td>
  574. HTML;
  575. $dom->load($str);
  576. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5>grams');
  577. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5>grams');
  578. assert($dom==$str);
  579. $str = <<<HTML
  580. <td><b>test :</b>1 gram but 5 >grams</td>
  581. HTML;
  582. $dom->load($str);
  583. assert($dom->find('td', 0)->innertext==='<b>test :</b>1 gram but 5 >grams');
  584. assert($dom->find('td', 0)->plaintext==='test :1 gram but 5 >grams');
  585. assert($dom==$str);
  586. // -----------------------------------------------------------------------------
  587. // BAD HTML test
  588. $str = <<<HTML
  589. <strong class="see <a href="http://www.oeb.harvard.edu/faculty/girguis/">http://www.oeb.harvard.edu/faculty/girguis/</a>">.</strong></p>
  590. HTML;
  591. $dom->load($str);
  592. // -----------------------------------------------
  593. $str = <<<HTML
  594. <a href="http://www.oeb.harvard.edu/faculty/girguis\">http://www.oeb.harvard.edu/faculty/girguis/</a>">
  595. HTML;
  596. $dom->load($str);
  597. // -----------------------------------------------
  598. $str = <<<HTML
  599. <strong class="''""";;''""";;\"\''''\"""''''""''>""'''"'" '
  600. HTML;
  601. $dom->load($str);
  602. // -----------------------------------------------------------------------------
  603. // tear down
  604. $dom->clear();
  605. unset($dom);
  606. ?>