PHP xpath() 函数
ການອະທິບາຍ ແລະ ການນໍາໃຊ້
xpath() 函数ດຳເນີນການສອບສວນ XPath XML Document.
ຖ້າສຳເລັດ, ຈະກັບຄືນຄືນອີກຢ່າງມີ SimpleXMLElement Object. ຖ້າບໍ່ສຳເລັດ, ຈະກັບຄືນ false.
ມູນວິທະຍາສາດ
class SimpleXMLElement
{
string xpath(path)
}
| ພວກມູນ | ອະທິບາຍ |
|---|---|
| path | ຕ້ອງການ. XPath 路າດ. |
ຕົວຢ່າງ
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body>Don't forget the meeting!</body> </note>
PHP 代码:
<?php
$xml = simplexml_load_file("test.xml");
$result = $xml->xpath("from");
print_r($result);
?>
ຄຳອອກ:
Array ( [0] => SimpleXMLElement Object ( [0] => John ) )

