Link to home
Start Free TrialLog in
Avatar of gvilla23
gvilla23Flag for United States of America

asked on

php variable to xml

I need to pass a variable in a link where I can search for a matching node (by id) in an xml file and display it
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

OK, what is the question?  

To pass a variable in a link you would find the variable in $_GET.  To find a node in an XML file, you would probably use the SimpleXML class to create an object and use an iterator like foreach to walk the object, comparing the XML information to the value you found in $_GET.

Do you have any experience in PHP programming?
Avatar of gvilla23

ASKER

How would i compare the XML information to the value in $_GET, in a foreach loop
Do you have some XML to test with?  If so, please post a small sample and tell me what you want to find inside the XML.  I'll show you the code.

Do you have experience in PHP programming?
Thanks, I want to be able to grab the node by the id, from  somthing like  
<a href="somelink.com?id=1">

I have a little PHP experience


<?xml version="1.0" encoding="ISO-8859-1"?>

<popups>
<popup>
<id>1</id>
<title>SQUARE ENIX MEMBERS REWARDS 2009</title>
<img_loc>images/se_member/se_members_popup_2.jpg</img_loc>
<client>SQUARE ENIX</client>
<involvement>DESIGN, FROM CONCEPT TO FINAL PACKAGING</involvement>
</popup>

<popup>
<id>2</id>
<title>ADENALIN MISFITS</title>
<img_loc>images/adrenaline_misfits/adrenaline_misfits_popup_1.jpg</img_loc>
<client>KONAMI</client>
<involvement>KEYART DESIGN</involvement>
</popup>

</popups>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is purfect =), one comment, how would I load the xml externally
 for example   $objDOM->load("test.xml"); and not include it on the page.
You can use this function to load an external XML file http://php.net/manual/en/function.simplexml-load-file.php

Thanks for the points, ~Ray