php registerxpathnamespace() 函数
实例
为下一个 xpath 查询创建命名空间上下文:
<?php $xml=<<<xml<book xmlns:chap="http://example.org/chapter-title"> <title>my book</title> <cha祝老师pter id="1"> &l东北三省旅游攻略t;chap:title>chapter 1</chap:title> <para&额外功gt;donec velit. nullam eget tellus...</para&分裂细胞gt; </chapter> <chapter id="2"> <chap:title>chapter 2</chap:title> <para>广东高考总分lorem ipsum dolor sit amet....</para> </chapter> </book> xml;$sxe=new simplexmlelement($xml); $sxe->registerxpathnamespace('c','http://example.org/chapter-title'); $result=$sxe->xpath('//c:title'); foreach ($result as $title) { echo $title . "<br>"; } ?>定义和用法
registerxpathnamespace()函数为下一个 xpath 查询创建命名空间上下文。
如果在 xml 文档中改变命名空间前缀,这个函数很有用。registerxpathnamespace()函数将创建一个指定的命名空间前缀,使受影响的 xml 节点可以在不改变应用程序代码太多的情况下进行访问。
语法
registerxpathnamespace( _prefix_ , _ns_ );
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对www.887551.com的支持。如果你想了解更多相关内容请查看下面相关链接
本文发布于:2023-04-06 15:56:16,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/895755ed212865b01f5b25997661307e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP registerXPathNamespace()函数讲解.doc
本文 PDF 下载地址:PHP registerXPathNamespace()函数讲解.pdf
| 留言与评论(共有 0 条评论) |