Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2007, 02:51 AM   PM User | #1
mrnightowl
New Coder

 
Join Date: Jul 2007
Posts: 78
Thanks: 6
Thanked 2 Times in 2 Posts
mrnightowl is an unknown quantity at this point
Multiple Xpath queries

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.


Code:
<?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 is offline   Reply With Quote
Old 10-11-2007, 11:35 AM   PM User | #2
mrnightowl
New Coder

 
Join Date: Jul 2007
Posts: 78
Thanks: 6
Thanked 2 Times in 2 Posts
mrnightowl is an unknown quantity at this point
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...

Code:
<?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');
?>
mrnightowl is offline   Reply With Quote
Old 10-11-2007, 04:18 PM   PM User | #3
angst
Senior Coder

 
angst's Avatar
 
Join Date: Apr 2004
Location: Toronto, Ontario
Posts: 2,112
Thanks: 15
Thanked 122 Times in 122 Posts
angst is on a distinguished road
is this using the SimplerXML function XPath?
angst is offline   Reply With Quote
Old 10-12-2007, 02:21 AM   PM User | #4
mrnightowl
New Coder

 
Join Date: Jul 2007
Posts: 78
Thanks: 6
Thanked 2 Times in 2 Posts
mrnightowl is an unknown quantity at this point
Quote:
Originally Posted by angst View Post
is this using the SimplerXML function XPath?
Using Xpath.class.php from SourceForge....

But I am trying simplexml using following:

Code:
<?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

Last edited by mrnightowl; 10-12-2007 at 12:14 PM..
mrnightowl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:48 PM.


Advertisement
Log in to turn off these ads.