config.XML文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<? xml version = "1.0" encoding = "UTF-8" ?> < node > < student > < name >张明</ name > < email >1234567890@qq.com</ email > < username >一样菜</ username > < code >985931</ code > </ student > < student > < name >王红</ name > < email >2345678901@qq.com</ email > < username >冰封</ username > < code >5625362</ code > </ student > </ node > |
php文件:
1
2
3
4
5
6
7
|
<?php $file = 'config/config.xml' ; $xml_array =simplexml_load_file( $file ); //将XML中的数据,读取到数组对象中 foreach ( $xml_array as $tmp ){ echo $tmp ->name. ": " . $tmp ->email. ", " . $tmp ->username. ", " . $tmp ->code. "<br>" ; } ?> |
结果
1
2
|
张明: 1234567890@qq.com, 一样菜, 985931 王红: 2345678901@qq.com, 冰封, 5625362 |
原文链接:http://www.cnblogs.com/mypsq/p/5576306.html
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容