<?php
/*
<?xml version="1.0" encoding="utf-8"?>
<article>
<item>
<title name="t1">11</title>
<content>content1</content>
<pubdate>2009-10-11</pubdate>
</item>
<item>
<title name="t2">title2</title>
<content>content2</content>
<pubdate>2009-11-11</pubdate>
</item>
</article>
*/
if(!function_exists('l')) {
function l() {
echo '<br/>***********************************<br />';
}
}
if(file_exists('test10_12.xml')) {
$xml = simplexml_load_file('test10_12.xml');
// xpath
$query = $xml->xpath('//title[@name="t1"]/ancestor::item');
var_dump($query);
l();
// title new
$query[0]->title->addChild('new','new');
// title fuck
$query[0]->title->addAttribute('fuck','fuck you');
// content hello,world
$query[0]->content = 'hello,world';
// ,
$query[0]->asXML("10.xml");
}
?>