Edit xml with form

Hi, I have several very cool applications that use xml, however my clients have no idea how to update an XML file so I want to create a form interface that will allow them to update the info inside the XML with a simple asp or php form.  ASP would be better right now as the application I have in mind is on a Windows Server.  Tutorials or pre-built applications will do fine.

Thanks
Webman04Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Windows runs PHP just fine.

Given that XML is, as its name implies, "extensible" you would probably have to write a custom application to take the XML file from the file system, populate the form fields on the form page, then write an action script to take the input from the form page and rewrite the XML file into the file system.  Along the way, you will need to do the appropriate editing and checking to be sure that the input data does not violate your business rules or "break" the XML with such stuff as incorrect entity codes.

If you would like a simple PHP example, post back here and I will show you how I would handle this.

best regards, ~Ray
0
Webman04Author Commented:
Hi, yes please, that would be great!

0
Ray PaseurCommented:
Here is one sample.  Read it over and I will see if I have another or can come up with something more to add.

One strategy to build on this might be to read the XML out of a file, and create the form script by using the XML field names.  A word of warning about this - the programming is likely to become complicated if there are a lot of nested fields and optional values in the XML tags!

HTH, ~Ray
<?php // RAY_post_to_xml.php
 
// IF WE HAVE DATA, PROCESS IT INTO XML
if (!empty($_POST))
{
 
// DISCARD GARBAGE
    unset($_POST["_submit"]);
 
// SET UP XML HEADER
    $xml = '<?xml version="1.0"?>' . "\n";
 
// SET UP A WRAPPER
    $xml .= '<results>' . "\n";
 
// ITERATOR - GET ALL FIELDS IN POST STREAM
    foreach ($_POST as $key => $value)
    {
        $xml .= "<$key>";
        $xml .= urlencode($value);
        $xml .= "</$key>\n";
    }
 
// CLOSE OFF THE WRAPPER
    $xml .= '</results>' . "\n";
 
// SHOW WHAT WE GOT
    echo "<pre>";
    echo htmlentities($xml);
 
// SET UP MAIL
    mail ("you@your.org", "XML HERE", $xml);
}
?>
<form action="<?=$PHP_SELF?>" method="post">
<input name="field1" />
<input name="field2" />
<input type="submit" value="Go" name="_submit" />
</form>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Webman04Author Commented:
OK I'll give this a try, thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.