2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="Players of Liverpool F.C." />
<meta name="keywords" content="liverpool, players of liverpool" />
<title>Players of Liverpool F.C.</title>
</head>
<body>
<?php
$dom = new DOMDocument();
$dom->loadHTMLFile('http://en.wikipedia.org/wiki/Liverpool_F.C.');
$domxpath = new DOMXPath($dom);
foreach ($domxpath->query('//span[@id="Players"]/../following-sibling::table[1]//span[@class="fn"]') as $a)
{echo
"
<p>$a->textContent</p>
";
};
?>
</body>
</html>
你好,我該如何解析一個包含所有$a->textContent
的XML的標籤,如<player></player>
?PHP XML解析器問題
你wan將球員列表提取到您自己的xml文檔中?或者只是將玩家粘貼到上面粘貼的這個頁面中? –