PHP函数getDocNamespaces介绍
定义和用法
getDocNamespaces() 函数从 SimpleXMLElement 对象返回在 XML 文档中声明的命名空间。
如果成功,该函数返回包含命名空间名称(带有关联的 URL)的数组。如果失败,则返回 false。
语法
class SimpleXMLElement{string getDocNamespaces(recursive)}
例子
XML 文件:
<?xml version="1.0" encoding="ISO-8859-1"?><note xmlns:b="http://www.w3school.com.cn/example/"><to>George</to><from>John</from><heading>Reminder</heading><b:body>Dont forget the meeting!</b:body></note>
PHP 代码:
<?phpif (file_exists(test.xml)) { $xml = simplexml_load_file(test.xml); }print_r($xml->getDocNamespaces());?>
输出类似:
Array([b] => http://www.w3school.com.cn/example/)
本文出自:琅枫个人博客。如需转载请注明出处!
本文出处:"https://www.langfujun.top/function/445.html"
如果您觉得文章对你有帮助,可以进行打赏。
打赏多少,您高兴就行,谢谢您对琅枫博客的支持! ~(@^_^@)~
微信打赏

支付宝打赏
