0
我有一個從Web服務解析HTML文檔PHP
<?php
$speechText=$_POST['spokentext'];
echo $speechText.'!';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://nlp.stanford.edu:8080/parser/index.jsp');
curl_setopt($ch, CURLOPT_POST, 3);
curl_setopt($ch,CURLOPT_POSTFIELDS, "query=".$speechText."&parserSelect=English&parse=Parse");
$result = curl_exec($ch);
//echo $result;
curl_close($ch);
$dom = new DOMDocument();
$dom->loadHTML($result);
$xpath = new DOMXPath($dom);
$result = $xpath->query('/html/body/div[2]/div[5]/pre');
echo $result->item(0)->nodeValue;
?>
提取信息的PHP代碼的變量$導致持有其返回的HTML文檔。我想通過解析它從中提取一些信息。我正在使用內置的DOM解析器,但是出現此錯誤 -
PHP Notice: Trying to get property of non-object
什麼是錯誤?
P.S. - 我在編程的完整的n00b:P
http://php.net/domdocument – cmbuckley 2015-04-03 16:22:35
請:http://bit.ly/1NGQpUF – 2015-04-03 16:24:53
@cmbuckley 一些簡單的幫助如何解析它?訪問特定的類/ ID? – GokuShanth 2015-04-03 16:26:10