Jump to content

XML to PHP


Bayler

Recommended Posts

in an attempt to parse out data from www.xfire.com ...

 

example: http://www.xfire.com/xml/sgteversmen/screenshots/

 

and using a parser from: www.criticaldevelopment.net/xml/

 

allows me to display all information like this:

 

foreach($parser->document->screenshot as $screenshots){
$images = $screenshots->filename[0]->tagData;
}

 

Question now is..

how can i display ALL of the Game Titles..but only one time each ?

Link to comment
https://forums.phpfreaks.com/topic/84394-xml-to-php/
Share on other sites

Not sure about the exact syntax for using the xml parser, but you can just put the titles into an array:

 

foreach($parser->document->screenshot as $screenshots){
  $images = $screenshots->filename[0]->tagData;
  if (!in_array($screenshots->game[0]->tagData, $game_titles)) {
    $game_titles[] = $screenshots->game[0]->tagData;
  }
}

array_map(create_function('$g_t', 'echo "Title: $g_t\n"'), $game_titles);

Link to comment
https://forums.phpfreaks.com/topic/84394-xml-to-php/#findComment-429903
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.