PHP xpath()函數(shù)講解
PHP xpath() 函數(shù)
定義和用法
xpath()函數(shù)運(yùn)行對(duì) XML 文檔的 XPath 查詢(xún)。
如果成功,該函數(shù)返回 SimpleXMLElements 對(duì)象的一個(gè)數(shù)組。如果失敗,則返回 FALSE。
語(yǔ)法
class SimpleXMLElement
{
string xpath(path)
}

實(shí)例
XML 文件
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
PHP 代碼
<?php
$xml = simplexml_load_file("test.xml");
$result = $xml->xpath("from");
print_r($result);
?>
上面的代碼將輸出:
Array ( [0] => SimpleXMLElement Object ( [0] => Jani ) )
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
相關(guān)文章
用PHP實(shí)現(xiàn)標(biāo)準(zhǔn)的IP Whois查詢(xún)
用PHP實(shí)現(xiàn)標(biāo)準(zhǔn)的IP Whois查詢(xún)...2006-10-10
一個(gè)簡(jiǎn)單實(shí)現(xiàn)多條件查詢(xún)的例子
一個(gè)簡(jiǎn)單實(shí)現(xiàn)多條件查詢(xún)的例子...2006-10-10

