note 46211 deleted from ref.simplexml by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 02 Oct 2004 16:57:44 +0000 |
| Subject: | note 46211 deleted from ref.simplexml by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77754@lists.php.net to get a copy of this message | ||
Note Submitter: virtualis at bol dot com dot br
----
Edit and write your xml files:
xml file: write.php (save as .php to avoid source viewing)
<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
<city>Los Angeles</city>
<state>California</state>
<country>2003</country>
</data>
php file to edit and save xml file:
<html>
<style>
body { font-family:verdana; font-size:13px; }
</style>
<body>
<?php
$s = simplexml_load_file('write.php');
if (isset($s1)) {
$s->city = $t1;
$s->state = $t2;
$s->country = $t3;
$handle= fopen('write.php', 'w');
$string = $s->asXML();
fputs($handle, $string);
fclose($handle);
echo "<script>window.status='Saved!';</script>";
}
echo "<table border=0>";
echo "<form name=f1 method=post action=writexml.php>";
echo "<tr><td>City:</td><td><input
onfocus=\"javascript:window.status='Editing!';\" type=text name=t1 value =
'$s->city'>";
echo "</tr><tr><td>State:</td><td><input
onfocus=\"javascript:window.status='Editing!';\" type=text name=t2 value =
'$s->state'>";
echo "</tr><tr><td>Country:</td><td><input
onfocus=\"javascript:window.status='Editing!';\" type=text name=t3 value =
'$s->country'>";
echo "</tr><tr><td> </td><td><input type=submit
name=s1 value='Save'>";
echo "</td></tr></table>";
?>
</body>
</html>