用xpath表达式查询出xml文档中年纪小于24岁的学生

WBOY
Release: 2016-06-13 11:58:05
Original
1020 people have browsed it

用xpath表达式查询出xml文档中年龄小于24岁的学生


   
      28年龄>   
   学生>
   
      23年龄>   
   学生>
   
      22年龄>   
   学生>
学生列表>

请问根据题目的要求,xls文档我该怎么写?请各位不吝赐教
------解决方案--------------------

$s =<<< XML<br /><?xml version="1.0" encoding="utf-8\"?><br /><学生列表><br />   <学生 姓名="王芳"><br />      <年龄>28</年龄>   <br />   </学生><br />   <学生 姓名="张海"><br />      <年龄>23</年龄>   <br />   </学生><br />   <学生 姓名="赵刚"><br />      <年龄>22</年龄>   <br />   </学生><br /></学生列表><br />XML;<br />$xml = simplexml_load_string($s);<br />foreach($xml->xpath("//*[年龄<24]") as $node) {<br />  echo $node->attributes() . ":" . $node->$b . PHP_EOL;<br />}<br />
Copy after login
张海:23
赵刚:22

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!