graham23s Posted August 26, 2007 Share Posted August 26, 2007 Hi Guys, i'm experimenting with reading .xml files currently i have: <?php $filecontent = file_get_contents("filename.xml"); $xml = new SimpleXMLElement($filecontent); echo $xml->asXML(); ?> this works great, it reads back in a nice format the contents of the .xml file, but im wanting to take information from the .xml file and store them in variables for later use but i'm not sure how to search the .xml file and take what i want, any advice would be great cheers guys Graham Quote Link to comment Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 xpath() is one way. Can you be more specific? Quote Link to comment Share on other sites More sharing options...
graham23s Posted August 26, 2007 Author Share Posted August 26, 2007 Hi B, for example in this .xml file there is a posters name: <file poster="someone@somewhere.com" i was wanting to read the .xml grab who the poster is and store it in a variable if possible thanks mate Graham Quote Link to comment Share on other sites More sharing options...
jscix Posted August 26, 2007 Share Posted August 26, 2007 http://www.ibm.com/developerworks/library/x-xmlphp1.html Quote Link to comment Share on other sites More sharing options...
Barand Posted August 26, 2007 Share Posted August 26, 2007 $xml = simplexml_load_file('myxml.xml'); foreach ($xml->xpath('//file') as $file) { echo "{$file['poster']} <br />"; } Quote Link to comment Share on other sites More sharing options...
graham23s Posted August 26, 2007 Author Share Posted August 26, 2007 Thamks a lot guys im gettin there lol Graham Quote Link to comment 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.