-2

我在这个 php xpath 应用程序中遇到错误,我无法修复,如果可能的话,我希望能得到一些帮助

 <?php
   //Get Username
    $username = $_GET["u"];

    $html = file_get_contents('http://us.playstation.com/publictrophy/index.htm?onlinename='     .$username);
    $html = tidy_repair_string($html);
    $doc = new DomDocument();
    $doc->loadHtml($html);
    $xpath = new DomXPath($doc);
    // Now query the document:
        foreach ($xpath->query('//*[@id="id-handle"]') as $node) {
        echo $node, "\n";
        }
        foreach ($xpath->query('//*[@id="leveltext"]') as $node1) {
        echo $node1, "\n";
        }
?>
4

1 回答 1

0

放在@前面,$dom->loadHTML($html)因为 loadHTML 通常会引起很多警告和通知

$dom = new DOMDocument();
@$dom->loadHTML($html);

$xpath = new DOMXPath($dom);
于 2013-01-02T21:02:47.543 回答