getNamespace函数语法
class SimpleXMLElement { string getNamespace(recursive) }
在本文中,我将解释PHP中使用的GetNamespace函数。
getNamespace()函数从一个简单的XML元素对象中获取XML文档中使用的命名空间。
getNamespace函数例子
XML文件
<?xml version="1.0" encoding="ISO-8859-1"?> <note xmlns:b="https://onitroad.com/articles/"> <book>iPhone</book> <writer>wei sang lee</writer> <name>Reminder</name> <b:body>Don't forget me this weekend!</b:body> </note>
PHP代码
<html> <body> <?php if (file_exists("parse.xml")) { $xml = simplexml_load_file("parse.xml"); } print_r($xml->getNamespaces()); ?> </body> </html>
日期:2020-04-11 23:04:31 来源:oir作者:oir