Jump to content

Archived

This topic is now archived and is closed to further replies.

jvargas

PHP / XML HELP!

Recommended Posts

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

Share this post


Link to post
Share on other sites
Try something like this:

[code]$output = "<album";
foreach($_POST as $key => $value)
{
$output .= " {$key}=\"{$value}\"";
}
$output .= " />";

echo $output;[/code]

Share this post


Link to post
Share on other sites
Hi,

Thank you for this. I apologize, but would you please explain the code.

Thank you.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.