getDocNamespaces() 函数从 SimpleXMLElement 对象返回在 XML 文档中声明的命名空间。
如果成功,该函数返回包含命名空间名称(带有关联的 URL)的数组。如果失败,则返回 false。
</>code
- class SimpleXMLElement
- {
- string getDocNamespaces(recursive)
- }
参数 | 描述 |
---|---|
recursive | 可选。规定是否返回父子节点中的所有命名空间。默认是 false。 |
XML 文件:
</>code
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <note xmlns:b="https://www.365jz.com/example/">
- <to>George</to>
- <from>John</from>
- <heading>Reminder</heading>
- <b:body>Don't forget the meeting!</b:body>
- </note>
PHP 代码:
</>code
- <?php
- if (file_exists('test.xml'))
- {
- $xml = simplexml_load_file('test.xml');
- }
- print_r(
$xml->getDocNamespaces()
);- ?>
输出类似:
</>code
- Array
- (
- [b] => https://www.365jz.com/example/
- )
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号