Parse and Load XML using PHP , Listbox , Textbox

Hi

I'm quite new to PHP programing and I need help / code for the following.

I have attached XML file that I need to parse see attached.

I need to parse it and build in HTML:

1. Listbox to show all the Descriptions

Once I click on any description in the Listbox following happens:
a. Lang listbox is populated/selected with relevant language (possible 4 , can be less used) (multiselection)
b. URL textbox is populated
c. Desc textbox is populated

2. User will be able to update the information

3. User can delete the movie

4. User will be able to save it back to the xml file all the changes that were done.

Only XML as DB allowed.

Any ideas/code. (Giving a lot of points here :-) )

Thank you.
Evgeny (evgeny.gol@gmail.com)
<?xml version="1.0" encoding="ISO-8859-1"?>
<videos>
<video url="http://www.youtube.com/v/QDQSUS3dUZg" lang="English,Russian,Hebrew,French" desc="Fish Tank" />
<video url="http://www.youtube.com/v/AfhT3Jui5jk" lang="English,Russian,Hebrew" desc="Jirenosvksi" />
</videos>

Open in new window

jekamanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

jausionsCommented:
If you're using PHP5, use SimpleXML to parse the XML document and extract the values. Use explode() function to know which "lang" where selected.

To save the data, you can either use the DOM extension, or simply write the XML.

When writing to a file, make sure you lock it first using the flock() function.
0
jekamanAuthor Commented:
Can you create a short sample ?
0
jausionsCommented:
Check Example #5 "Using attributes" here: http://www.php.net/manual/en/simplexml.examples.php
0
jekamanAuthor Commented:
I know how to parse the XML file , but I need a little help how to PARSE and load the valies to the list/textbox.
0
jausionsCommented:
Here's something that should get you in the right direction. (I had it done yesterday, but Expert-Exchange was doing maintenance)
<?php
 
$xmlstr = '<?xml version="1.0" encoding="ISO-8859-1"?>
<videos>
<video url="http://www.youtube.com/v/QDQSUS3dUZg" lang="English,Russian,Hebrew,French" desc="Fish Tank" />
<video url="http://www.youtube.com/v/AfhT3Jui5jk" lang="English,Russian,Hebrew" desc="Jirenosvksi" />
</videos>';
 
$xml = new SimpleXMLElement($xmlstr);
 
$langs = array('English', 'Russian', 'Hebrew', 'French');
 
?>
<form action="blah.php" method="POST">
<?php
$i = 0;
foreach ($xml->video as $video) {
    $url = htmlspecialchars((string)$video['url']);
    $desc = htmlspecialchars((string)$video['desc']);
    $lang = explode(',', (string)$video['lang']);
 
    echo '<p><input type="text" name="url['.$i.']" value="'.$url.'" />
             <textearea name="desc['.$i.']">'.$desc.'</textarea>
             <select multiple="multiple" name="lang['.$i.'][]">';
    foreach ($langs as $l) {
        $selected = (in_array($l, $lang)) ? ' selected="selected"' : '';
        echo '<option value="'.$l.'"'.$selected.'>'.$l.'</option>';
    }
    echo '</select></p>';
    ++$i;
}
?>
</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
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.