PHP xpath()函数讲解
作者:php参考手册 时间:2023-06-04 07:03:38
PHP xpath() 函数
定义和用法
xpath()
函数运行对 XML 文档的 XPath 查询。
如果成功,该函数返回 SimpleXMLElements 对象的一个数组。如果失败,则返回 FALSE。
语法
class SimpleXMLElement
{
string xpath(path)
}
实例
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
)
)
标签:php,xpath(),函数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python 实现大整数乘法算法的示例代码
2022-07-07 02:57:54
php中session使用示例
2024-04-30 08:46:58
Javascript实现通过选择周数显示开始日和结束日的实现代码
2023-08-23 13:44:52
python+OpenCV实现图像拼接
2023-01-28 08:09:26
![](https://img.aspxhome.com/file/2023/2/113112_0s.jpg)
浅谈python3打包与拆包在函数的应用详解
2022-03-05 00:33:15
![](https://img.aspxhome.com/file/2023/1/101201_0s.png)
详解Go strconv包
2024-04-23 09:42:08
python如何为list实现find方法
2022-01-14 09:15:56
python语言中pandas字符串分割str.split()函数
2022-01-30 16:55:56
python 实现识别图片上的数字
2021-06-17 13:09:31
![](https://img.aspxhome.com/file/2023/6/127796_0s.jpg)
Python聚类算法之DBSACN实例分析
2021-03-26 00:11:10
![](https://img.aspxhome.com/file/2023/7/120607_0s.png)
python中使用input()函数获取用户输入值方式
2021-06-23 04:03:11
![](https://img.aspxhome.com/file/2023/7/104947_0s.jpg)
Python 正则表达式实现计算器功能
2023-09-02 02:01:44
![](https://img.aspxhome.com/file/2023/1/93511_0s.png)
Python读写JSON文件的操作详解
2021-03-22 11:46:35
![](https://img.aspxhome.com/file/2023/0/82670_0s.jpg)
SQL Server 2005中的CLR集成
2009-03-10 15:07:00
Python OpenCV之图片缩放的实现(cv2.resize)
2023-01-08 14:02:48
![](https://img.aspxhome.com/file/2023/6/89206_0s.jpg)
python如何删除字符串最后一个字符
2022-06-07 14:14:04
Python Selenium自动化获取页面信息的方法
2023-08-22 18:29:31
更改localhost为其他名字的方法
2023-11-23 08:07:52
MYSQL教程:服务器优化和硬件优化
2009-02-27 15:43:00
使用Python制作一盏 3D 花灯喜迎元宵佳节
2021-08-15 06:35:43
![](https://img.aspxhome.com/file/2023/1/118621_0s.gif)