手机
当前位置:查字典教程网 >编程开发 >php教程 >PHP XML数据解析代码
PHP XML数据解析代码
摘要:复制代码代码如下://xmlstring$xml_string="Foofoo@bar.comFoobarfoobar@foo.com";/...

复制代码 代码如下:

//xml string

$xml_string="<?xml version='1.0'?>

<users>

<user id='398'>

<name>Foo</name>

<email>foo@bar.com</name>

</user>

<user id='867'>

<name>Foobar</name>

<email>foobar@foo.com</name>

</user>

</users>";

//load the xml string using simplexml

$xml = simplexml_load_string($xml_string);

//loop through the each node of user

foreach ($xml->user as $user)

{

//access attribute

echo $user['id'], ' ';

//subnodes are accessed by -> operator

echo $user->name, ' ';

echo $user->email, '<br />';

}

这里是摘自查字典教程网之前发布的文章。更多的技巧可以参考。

收集的二十一个实用便利的PHP函数代码

【PHP XML数据解析代码】相关文章:

PHP的MVC框架 深入解析

PHP CURL 多线程操作代码实例

PHP5的XML新特性

用PHP实现XML备份Mysql数据库

图形数字验证代码

用PHP来写记数器(详细介绍)

PHP 和 MySQL 基础教程(四)

PHP SPL标准库中的常用函数介绍

PHP SOCKET 技术研究

PHP滚动日志的代码实现

精品推荐
分类导航