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 Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/ 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? Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/#findComment-334476 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="[email protected]" i was wanting to read the .xml grab who the poster is and store it in a variable if possible thanks mate Graham Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/#findComment-334483 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 Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/#findComment-334491 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 />"; } Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/#findComment-334499 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 Link to comment https://forums.phpfreaks.com/topic/66745-simplexmlelement-and-reading-xml-files/#findComment-334525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.