Jump to content

surfnjunkie

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.surfnjunkie.com

Profile Information

  • Gender
    Male
  • Location
    California

surfnjunkie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am having a problem with this code working on one server, but not on the other server. This is the code that I am using: $xml2 = simplexml_load_file("https://p2.myserver.com/app/apixml.php?project=My%20Videos&user=myusername&id=myfancyid"); foreach($xml2->medialist->media as $media){ $http = $media->http; echo "<br>$http"; } Here is a sample portion of the xml output: <playlist version='1' xmlns='http://xspf.org/ns/0/'> <medialist> <media> <videosource>http://mdv1.net/videos/HuluAdsTranscode_2813_FLASH_700K_16x9_29.97_x264.mp4</videosource> <thumb>http://p2.myserver.com/img/My_Videos/a07390b682df54d4fd837f56960b6ffc.jpg</thumb> <project>My Videos</project> <rtsp>rtsp://p2.myserver.com/c2aba58ea880bd54fe7eef54f4b8d822.sdp</rtsp> <http>http://p2.myserver.com/c2aba58ea880bd54fe7eef54f4b8d822.sdp</http> </media> <media> <videosource>http://mdv1.net/videos/HuluAdsTranscode_2805_1073_FLASH_700K_4x3_29_97_x264.mp4</videosource> <thumb>http://p2.myserver.com/img/My_Videos/d464c582d02935ac3af5d7f224cfc211.jpg</thumb> <project>My Videos</project> <rtsp>rtsp://p2.myserver.com/461ea4a66063e1e95eec11dde824d10c.sdp</rtsp> <http>http://p2.myserver.com/461ea4a66063e1e95eec11dde824d10c.sdp</http> </media> </medialist> </playlist> On my testing server I am getting a response that I would expect: http://p2.myserver.com/c2aba58ea880bd54fe7eef54f4b8d822.sdp http://p2.myserver.com/461ea4a66063e1e95eec11dde824d10c.sdp the output of the 2 files. But on my other server I am getting this error: Warning: simplexml_load_file() [function.simplexml-load-file]: https://p2.tipmotion.com/app/apixml2.php?project=My%20Videos&user=YWpib2xhbm9z&id=YWFyb24=:1: parser error : Document is empty in /home/mdvcom5/public_html/a/index.php on line 34 Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/mdvcom5/public_html/a/index.php on line 34 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/mdvcom5/public_html/a/index.php on line 34 Warning: simplexml_load_file() [function.simplexml-load-file]: https://p2.tipmotion.com/app/apixml2.php?project=My%20Videos&user=YWpib2xhbm9z&id=YWFyb24=:1: parser error : Start tag expected, '<' not found in /home/mdvcom5/public_html/a/index.php on line 34 Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/mdvcom5/public_html/a/index.php on line 34 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/mdvcom5/public_html/a/index.php on line 34 Warning: Invalid argument supplied for foreach() in /home/mdvcom5/public_html/a/index.php on line 35 I wanted to see if anyone has any idea why this could be happening? or if there is anything on the server I need to change.
  2. I figured it out, and was able to get the script to do what I wanted it to do. I thought I would post my solution. <?php $mySearch = 0; $isbnSearch = "54321"; $xml = simplexml_load_file('booklist.xml'); foreach($xml->booklist->book as $book){ if($book->isbn == $isbnSearch){ $title = $book->title; $mySearch = 1; } } if($mySearch == 1){ echo "We Found your Book" . $title; } else { echo "Sorry we could not find your book" . $isbnSearch; } ?>
  3. Basically what I am trying to do is search an xml files elements. In this example I am searching for a books ISBN. If the ISBN is found I would like it to show the book title. If it is not found in any of the <isbn> element tags then I would like to be able to have it echo a message that the ISBN can not be found only 1 time. Here is the sample xml: <?xml version="1.0" encoding="utf-8"?> <catalog> <booklist> <book> <title>Cat in the hat</title> <image>cat.jpg</image> <isbn>12345</isbn> <link>http://amazon.com/book/cat_in_the_hat/</link> </book> <book> <title>Guerrila Marketing</title> <image>guerrilla.jpg</image> <isbn>54321</isbn> <link>http://amazon.com/book/guerrilla/</link> </book> <book> <title>The 48 Laws of Power</title> <image>power.jpg</image> <isbn>86543</isbn> <link>http://amazon.com/book/48_Laws_of_Power</link> </book> </booklist> </catalog> Here is the code: <?php // Will use simplexml to load xml file $xml = simplexml_load_file('booklist.xml'); // Will search the isbn 12345 $isbnSearch = "54321"; foreach($xml->booklist->book as $book){ if($book->isbn == $isbnSearch) echo "Your book is: " . $book->title . "<br>"; // would like it to stop here if <isbn> and $isbnSearch match // if no <isbn> elements match $isbnSearch if($book->isbn != $isbnSearch) // would like it to echo 1 time and not for each isbn. echo "Your book with ISBN:" . $isbnSearch . " could not be found<br>"; } ?> I have tried a few different things, but I keep hitting a wall. I tried setting up the xml into an array, but I couldn't get that quite right. If anyone can get me pointed in a better direction any help would be greatly appreciated.
×
×
  • 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.