saving xml data via php and using $vairables -
saving xml data via php and using $vairables -
i have seen many questions on here regarding saving info xml , have managed create form (thanks guys asked , answered), there 1 minor blip
here code know mean
<?php function insertxml($iname,$iurl) { $doc = new domdocument; //$doc->preservewhitespace = false; $doc->load("bookmark.xml"); // want nice output //$doc->formatoutput = true; $root = $doc->getelementsbytagname('bookmark')->item(0); $title = $doc->createelement('url', $iurl); $domattribute = $doc->createattribute('name'); $domattribute->value = ('$iname'); $title->appendchild($domattribute); $newtitle = $root->appendchild($title); echo 'wrote: ' . $doc->save("bookmark.xml") . ' bytes'; // wrote: 72 bytes } $name = $_post['name']; $url = $_post['url']; insertxml($name,$url); ?>
and form looks so:
<!doctype html> <html> <head> <title> xml reader</title> </head> <body> <form action="index.php" method="post"> name: <input type="text" name="name"><br> url: <input type="text" name="url"><br> <input type="submit"> </form> </body> </html>
the code works fine when set 'test' in name box , 'http://test.com' in url box comes out this:
<url name="$iname">http://test.com</url>
what is
<url name="test">http://test.com</url> <url name="(what ever name set in name box)">(what ever name set in url box)</url>
ultimatly syntax should set following?:
$title = $doc->createelement('url', $iurl);
remove quotes variable
('$iname')
should
($iname)
then remove braces not needed, (there nil group):
($iname)
should be
$iname
php xml
Comments
Post a Comment