Home  >  Article  >  php教程  >  php 读取xml的方法二---simplexml读取xml

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

PHP中文网
PHP中文网Original
2016-05-25 17:14:57965browse

 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>";
}
 
?>


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


Statement:
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
Previous article:数据库操作类Next article:php实时倒计时