Kibit Posted February 3, 2008 Share Posted February 3, 2008 I have to be honest, I have absolutely no idea how to go about this but I think for someone who's done this sort of thing before I'd be a 2 sec doddle of a job. I want to pull some info (but not all) out of an XML file Here is the file.. http://www.wsad.co.uk/tm/ajax.php?plugin=Website&autologin=true&server_id=1 And all I wanna pull out is <name> <type> <currentchallenge> <players> If someone could code that in php with a plain text output I would be extremely grateful. Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/ Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Take a look at the simplexml extension. It really is, as the name implies, simple. Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456803 Share on other sites More sharing options...
Kibit Posted February 3, 2008 Author Share Posted February 3, 2008 Take a look at the simplexml extension. It really is, as the name implies, simple. Thanks but it seems not simple enough for a n00b like me.. Here is what I've done.. <?php $xml = http://www.wsad.co.uk/tm/ajax.php?plugin=Website&autologin=true&server_id=1; echo $xml->name[0]->plot; // "So this language. It's like..." ?> And I get Parse error: syntax error, unexpected ':' in /home/wsad/public_html/tm/test.php on line 3 If someone could just get me started with a basic working bit of php I'm sure I'll be able to work it out. Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456815 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 Try... <?php $xml = simplexml_load_file("http://www.wsad.co.uk/tm/ajax.php?plugin=Website&autologin=true&server_id=1"); echo $xml->name[0]->plot; // So this language. It's like... ?> Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456817 Share on other sites More sharing options...
Kibit Posted February 3, 2008 Author Share Posted February 3, 2008 Thanks for the quick reply, that clears the error but I now just get a plain white page, How do I now tell it what info I want to display? Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456823 Share on other sites More sharing options...
Kibit Posted February 3, 2008 Author Share Posted February 3, 2008 I now have a basic working page using the following code... <?php $xml = simplexml_load_file("http://www.wsad.co.uk/tm/ajax.php?plugin=Website&autologin=true&server_id=1"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } ?> The page is here.. http://www.wsad.co.uk/tm/test.php But as you can see that just outputs everything and I only want to show a couple of the details as outlined in the first post, Also where there are more than 1 result (I think its called an "array") such as... <players> − <item> <span class='tm-b'>[WSAD]<span style='color:#0f0'>Harding</span></span> </item> </players> Its not returning any results. Any further help would be very gratefully received and since I noticed your on a donation drive I could be convinced to donate ;-) Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456839 Share on other sites More sharing options...
Kibit Posted February 3, 2008 Author Share Posted February 3, 2008 Bump, Can anyone offer me any further help on this please. Quote Link to comment https://forums.phpfreaks.com/topic/89210-parse-xml-to-a-php-page-help-please/#findComment-456950 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.