Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts

    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);
    ?>

  • #2
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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');
    ?>

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    is this using the SimplerXML function XPath?

  • #4
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •