jvargas Posted October 11, 2006 Share Posted October 11, 2006 Hello everyone,First let me thank anyone who replies in advance.My dilema is as follows:I have an HTML form that sends information to a php script that writes an XML file for me. This is fine. The form contains 3 fields: id, path, name.What I need to do is continue to apend to the XML anytime the form is submited before the ending node.Here is an example:XML FILE <?xml version="1.0" encoding="UTF-8"?><gallery><album id="1" path="carShow" name="some auto show" /></gallery>Here is what I need to apend to the XML file:<?xml version="1.0" encoding="UTF-8"?><gallery><album id="1" path="carShow" name="some auto show" />[b][color=red]<album id="2" path="album" name="another album" />[/color][/b] <--- Information from the HTML form added here before the ending node.</gallery> [b]<---- Ending node[/b]Is this possible?Thank you.Jay Quote Link to comment https://forums.phpfreaks.com/topic/23687-php-xml-help/ Share on other sites More sharing options...
Daniel0 Posted October 11, 2006 Share Posted October 11, 2006 Try something like this:[code]$output = "<album";foreach($_POST as $key => $value){ $output .= " {$key}=\"{$value}\"";}$output .= " />";echo $output;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23687-php-xml-help/#findComment-107514 Share on other sites More sharing options...
jvargas Posted October 11, 2006 Author Share Posted October 11, 2006 Hi,Thank you for this. I apologize, but would you please explain the code. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/23687-php-xml-help/#findComment-107521 Share on other sites More sharing options...
Daniel0 Posted October 11, 2006 Share Posted October 11, 2006 Of course. First line assigns <album to $output.Then you run through each POST variable and add it to output, then you add the ' />' to close the tag. Finally it is echoed. Quote Link to comment https://forums.phpfreaks.com/topic/23687-php-xml-help/#findComment-107527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.