PHP attributes()函数讲解
PHP attributes() 函数
实例
返回 XML 的 body 元素的属性和值:
<?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body date="2013-01-01" type="private">Don't forget me this weekend!</body> </note> XML; $xml=simplexml_load_string($note); foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,""<br>"; } ?>
定义和用法
attributes()
函数返回 XML 标签的属性和值。
语法
attributes( _ns,is_prefix_ );
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对我们的支持。如果你想了解更多相关内容请查看下面相关链接
相关推荐
-
PHP asXML()函数讲解
PHP asXML()函数 实例 格式化 XML(版本 1.0)中的 SimpleXML 对象的数据: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </not
-
PHP count()函数讲解
PHP count() 函数 实例 计算 car 节点的子节点个数: <?php $xml=<<<XML <cars> <car name="Volvo"> <child/> <child/> <child/> <child/> </car> <car name="BMW"> <child/> <child/> </c
-
PHP simplexml_load_file()函数讲解
PHP simplexml_load_file() 函数 实例 转换 XML 文件为 SimpleXMLElement 对象,然后输出对象的键和元素: <?php $xml=simplexml_load_file("note.xml"); print_r($xml); ?> 定义和用法 simplexml_load_file()函数转换指定的 XML 文件为 SimpleXMLElement 对象. 语法 simplexml_load_file( _file,classna
-
PHP getDocNamespaces()函数讲解
PHP getDocNamespaces() 函数 实例 返回 XML 文档的根节点中声明的命名空间: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars xmlns:c="http://codingdict.com/ns"> <c:car id="1">Volvo</c:car>
-
PHP getName()函数讲解
PHP getName() 函数 实例 返回 XML 元素及其子元素的名称: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars> <car id="1">Volvo</car> <car id="2">BMW</car> <car id="3
-
PHP registerXPathNamespace()函数讲解
PHP registerXPathNamespace() 函数 实例 为下一个 XPath 查询创建命名空间上下文: <?php $xml=<<<XML <book xmlns:chap="http://example.org/chapter-title"> <title>My Book</title> <chapter id="1"> <chap:title>Chapter 1&l
-
PHP simplexml_import_dom()函数讲解
PHP simplexml_import_dom() 函数 实例 获取 DOM 文档节点并转换为 SimpleXML 节点: <?php $dom=new domDocument; $dom->loadXML("<note><to>Tove</to><from>Jani</from></note>"); $x=simplexml_import_dom($dom); echo $x->from; ?
-
PHP children()函数讲解
PHP children() 函数 实例 查找 note 节点的子节点: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> XML; $xml
-
PHP simplexml_load_string()函数实例讲解
PHP simplexml_load_string() 函数 实例 转换形式良好的 XML 字符串为 SimpleXMLElement 对象,然后输出对象的键和元素: <?php $note=<<<XML <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me thi
-
PHP getNamespaces()函数讲解
PHP getNamespaces() 函数 实例 返回 XML 文档中使用的命名空间: <?php $xml=<<<XML <?xml version="1.0" standalone="yes"?> <cars xmlns:c="http://codingdict.com/ns" xmlns:a="http://codingdict.com/country"> <c:c
随机推荐
- python3使用PyMysql连接mysql数据库实例
- 微信js-sdk分享功能接口常用逻辑封装示例
- QQ密码找回方法全攻略(QQ被盗怎么要回QQ密码呢)
- 未能在 sysdatabases 中找到数据库 aa1xxxx 所对应的条目。没有找到具有该名称的条目
- Ubuntu 用vsftpd 配置FTP服务器教程详解
- 谈谈Java中try-catch-finally中的return语句
- Asp.net 字符串操作基类(安全,替换,分解等)
- js代码实现微博导航栏
- PHP排序算法类实例
- PHP使用curl函数发送Post请求的注意事项
- magento后台无法登录解决办法的两种方法
- JS实现很酷的EMAIL地址添加功能实例
- 详解Ruby中正则表达式对字符串的匹配和替换操作
- Python代理抓取并验证使用多线程实现
- c++生成dll使用python调用dll的方法
- Android通过SharedPreferences实现自动登录记住用户名和密码功能
- 巧用jquery解决下拉菜单被Div遮挡的相关问题
- webpack3+React 的配置全解
- jquery下操作HTML控件的实现代码
- jQuery插件 Jqplot图表实例