php與xml聯絡緊密,下面是乙個較簡單的解析xml節點資料的例子,示例中自定義有乙個xml樣例檔案**,通過php將依次讀取出xml節點中的id、name和email資料,是讀取較大的xml檔案的前提,新手的話,那就更應該參考了:
01
<?php
02
//定義乙個xml樣例檔案
03
$xml_string
="<?xml version=
'1.0'
?>
04
05
06
foo
07
foo@bar.com
08
09
10
foobar
11
foobar@foo.com
12
13
";
14
//開始解析xml
15
$xml
= ******xml_load_string(
$xml_string
);
16
foreach
(
$xml
->user
as
$user
)
17
22
?>
快速讀取xml節點內容
xml內容如下 view code 1 promotion coupons get response 2 tot results 3200 4tot results 5 coupons list true 6 coupon 7 coupon id 8123456 9coupon id 10 deno...
讀取XML 內容
file f new file system.getproperty user.dir file.separator src userfile.xml 定位檔案 reader new saxreader try catch documentexception e e.printstacktrace ...
C 解析帶字首的Xml節點內容
他的結構是這樣子的 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 xmlversion 1.0 encoding utf 8 soap env envelopexmlns soap env soap env header transactionid 110...