note 46211 added to ref.simplexml
| From: | virtualis at bol dot com dot br | Date: | Sat, 02 Oct 2004 13:59:22 +0000 |
| Subject: | note 46211 added to ref.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77742@lists.php.net to get a copy of this message | ||
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>
----
Manual Page -- http://www.php.net/manual/en/ref.simplexml.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46211
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46211&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46211&report=yes
Search -- http://master.php.net/manage/user-notes.php