[ create a new paste ] login | about

Link: http://codepad.org/eMKjNyXL    [ raw code | output | fork ]

PHP, pasted on Oct 9:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

$brokenHTML = <<< HTML
<tabble>
    <tr>
        <td1><span>Foo</span>
        <td>Bar</td>
        <td>Baz</td>
    </tr>
</tabble>
HTML;

$dom = new DOMDocument;
$dom->loadHTML($brokenHTML);
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//tabble/tr/td1/span');

echo 
    $nodes->item(0)->nodeValue,
    PHP_EOL,
    $dom->saveHTML();


Output:
1
2
3
4
5
6
7
8
9
10

Warning: DOMDocument::loadHTML(): Tag tabble invalid in Entity, line: 1 on line 14

Warning: DOMDocument::loadHTML(): Tag td1 invalid in Entity, line: 3 on line 14
Foo
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><tabble><tr><td1><span>Foo</span>
        <td>Bar</td>
        <td>Baz</td>
    </td1></tr></tabble></body></html>


Create a new paste based on this one


Comments: