7/24/2009

Simplexml

讀檔:
$xml = simplexml_load_file("iv04dataset.xml");
if(!$xml) echo "fail";

找element(利用xpath找):
$t = $xml->xpath("/articles/article[@id='acm721078']");

讀value:
echo $t[0]->title;

讀attribute:
$attr = $t[0]->attributes();
echo $attr["id"];



0 comments: