...

View Full Version : Multiple Xpath queries



mrnightowl
10-11-2007, 03:51 AM
I'm using the following code to parse XML data from Justin.tv To show viewers for specific channels... The problem is I have 30 different xml files to pull from...1 for each channel.. ie this channel is tibtie/meta.xml another is justin/meta.xml When I load the page it just freezes... I assume the problem is that xpath is trying to open up 30 sockets at once to connect. Is there a way I can put a load order? Where it will parse em in a row ? Say 1/meta.xml then 2/meta.xml So on and so forth.



<?php
include("XPath.class.php");?>

<?php
$xp = new XPath();
$xp->importFromFile("http://www.justin.tv/tibtie/meta.xml");
$viewers = $xp->getData('//viewers');
echo($viewers);
?>

mrnightowl
10-11-2007, 12:35 PM
I've also tried the below method then echo the matching data to its proper location... works for the first 8 if I load more than that it freezes again...


<?php
require("XPath.class.php");
$tibtie = new XPath();
$tibtie->importFromFile("http://www.justin.tv/tibtie/meta.xml");
$tibtiev = $tibtie->getData('//viewers');
$myowl = new Xpath();
$myowl->importFromfile("http://www.justin.tv/myowl/meta.xml");
$myowlv = $myowl->getData('//viewers');
$ahhyeah = new Xpath();
$ahhyeah->importFromfile("http://www.justin.tv/ahhyeahforchrist/meta.xml");
$ahhyeahv = $ahhyeah->getData('//viewers');
$ron = new Xpath();
$ron->importFromfile("http://www.justin.tv/ronaldlewis/meta.xml");
$ronv = $ron->getData('//viewers');
$justin = new Xpath();
$justin->importFromfile("http://www.justin.tv/justin/meta.xml");
$justinv = $justin->getData('//viewers');
$justine = new Xpath();
$justine->importFromfile("http://www.justin.tv/ijustine/meta.xml");
$justinev = $justine->getData('//viewers');
$lisa = new Xpath();
$lisa->importFromfile("http://www.justin.tv/nekomimi_lisa/meta.xml");
$lisav = $lisa->getData('//viewers');
$morf = new Xpath();
$morf->importFromfile("http://www.justin.tv/starving_artist/meta.xml");
$morfv = $morf->getData('//viewers');
?>

angst
10-11-2007, 05:18 PM
is this using the SimplerXML function XPath?

mrnightowl
10-12-2007, 03:21 AM
is this using the SimplerXML function XPath?

Using Xpath.class.php from SourceForge....

But I am trying simplexml using following:



<?php
$xml = simplexml_load_file("http://www.justin.tv/ijustine/meta.xml");
echo $xml->viewers;
?>

But same results if try running it multiple times on the same page



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum