PHP XML數(shù)據(jù)解析代碼
更新時間:2010年05月26日 01:08:58 作者:
PHP解析XML 數(shù)據(jù)代碼,用于PHP讀取XML數(shù)據(jù)。
復制代碼 代碼如下:
//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 />';
}
這里是摘自腳本之家之前發(fā)布的文章。更多的技巧可以參考。
收集的二十一個實用便利的PHP函數(shù)代碼
您可能感興趣的文章:
- PHP實現(xiàn)動態(tài)添加XML中數(shù)據(jù)的方法
- PHP解析xml格式數(shù)據(jù)工具類示例
- PHP操作XML作為數(shù)據(jù)庫的類
- PHP中使用xmlreader讀取xml數(shù)據(jù)示例
- PHP生成和獲取XML格式數(shù)據(jù)的方法
- php操作XML、讀取數(shù)據(jù)和寫入數(shù)據(jù)的實現(xiàn)代碼
- php中實現(xiàn)xml與mysql數(shù)據(jù)相互轉(zhuǎn)換的方法
- php處理復雜xml數(shù)據(jù)示例
- PHP XML備份Mysql數(shù)據(jù)庫
- php操作xml并將其插入數(shù)據(jù)庫的實現(xiàn)方法
- PHP實現(xiàn)動態(tài)刪除XML數(shù)據(jù)的方法示例
相關(guān)文章
巧用php中的array_filter()函數(shù)去掉多維空值的代碼分享
在我們開發(fā)過程中,判斷數(shù)組為空時你會想到什么方法呢?首先想到的應(yīng)該是empty函數(shù),不過直接用empty函數(shù)判斷為空是不對的,因為當這個值是多維數(shù)的時候,empty結(jié)果是有值的2012-09-09
php set_time_limit()函數(shù)的使用詳解
本篇文章是對php中的set_time_limit()函數(shù)進行了詳細的分析介紹,需要的朋友參考下2013-06-06
淺談PHP的exec()函數(shù)無返回值排查方法(必看)
下面小編就為大家?guī)硪黄獪\談PHP的exec()函數(shù)無返回值排查方法(必看)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03

