Home > php教程 > PHP源码 > body text

php 读取xml的方法二---simplexml读取xml

PHP中文网
Release: 2016-05-25 17:14:57
Original
971 people have browsed it

 php 读取xml的方法二---simplexml读取xml

xml源文件
 
<?xml version="1.0 encoding="UTF-8"?>
  <humans>
  <zhangying>
  <name>张映</name>
  <sex>男</sex>
  <old>28</old>
  </zhangying>
  <tank>
  <name>tank</name>
  <sex>男</sex>
  <old>28</old>
  </tank>
  </humans>
 
 
<?php
$xml_array=simplexml_load_file(&#39;person.xml&#39;);                        //将XML中的数据,读取到数组对象中
 
foreach($xml_array as $tmp){
echo $tmp->name."-".$tmp->sex."-".$tmp->old."<br>";
}
 
?>
Copy after login


以上就是php 读取xml的方法二---simplexml读取xml的内容,更多相关内容请关注PHP中文网(www.php.cn)! 


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template