<?php
$xml = simplexml_load_file(dirname(__FILE__) . '/thedata.xml');
/* modify all item ids and titles */
foreach ($xml->item as $msg) {
$msg['id'] += 1000; // increase id by 1000
$msg->title .= ' ( was modified ) '; // indicate that data was changed
}
/* output modified XML document */
echo '<pre>' . htmlspecialchars($xml->asXML()) . '</pre>';
?>
<?xml version="1.0"?>
<forum uri="http://fud.prohost.org/forum/index.php">
<item id="11084">
<title>Binary Protocols vs XML ( was modified ) </title>
<link>http://fud.prohost.org/forum/index.php/m/10084</link>
<description>Why does everyone insist on using XML?</description>
</item>
<item id="11149">
<title>How do I post messages? ( was modified ) </title>
<link>http://fud.prohost.org/forum/index.php/m/10149</link>
<description>I can post messages, help!</description>
</item>
</forum>