0

i am trying to get remote RSS feed content in PHP array and do some stuff on it., i am using simplexml_load_file to convert RSS in to an Array

e.g.

<?php $raw_array = simplexml_load_file('https://kickass.to/new/rss/'); print_r($raw_array); ?> 

gives output

SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => Latest New Torrents RSS Feed - KickassTorrents [link] => http://kat.cr/ [description] => Latest New Torrents RSS Feed [item] => Array ( [0] => SimpleXMLElement Object ( [title] => title [category] => category [author] => http://kat.cr/user/author/ [link] => http://kat.cr/link.html [guid] => http://kat.cr/link.html [pubDate] => Mon, 18 May 2015 16:02:48 +0000 [enclosure] => SimpleXMLElement Object ( [@attributes] => Array ( [url] => http://torcache.net/torrent/hash.torrent [length] => 83475908 [type] => application/x-bittorrent ) ) ) 

but when i go to RSS FEED directly and view source , it shows .

<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:torrent="http://xmlns.ezrss.it/0.1/"> <channel> <title>Latest New Torrents RSS Feed - KickassTorrents</title> <link>http://kat.cr/</link> <description>Latest New Torrents RSS Feed</description> <item> <title>titletitletitle</title> <category>category- Video</category> <author>http://kat.cr/user/author/</author> <link>http://kat.cr/link.html</link> <guid>http://kat.cr/guid.html</guid> <pubDate>Mon, 18 May 2015 15:36:42 +0000</pubDate> <torrent:contentLength>125153743</torrent:contentLength> <torrent:infoHash>212E859FB1BAFEA38BAB91BF3D94BB0DBB0ABFE4</torrent:infoHash> <torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:212E859FB1BAFEA38BAB91BF3D94BB0DBB0ABFE4&dn=titletitle=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI> <torrent:seeds>0</torrent:seeds> <torrent:peers>0</torrent:peers> <torrent:verified>1</torrent:verified> <torrent:fileName>fileName.torrent</torrent:fileName> <enclosure url="http://torcache.net/torrent/212E859FB1BAFEA38BAB91BF3D94BB0DBB0ABFE4.torrent?title=[kat.cr]the.art.of.cocksucking.pir.te" length="125153743" type="application/x-bittorrent" /> </item> 

so when i use simplexml_load_file not all sub items/elements are getting parsed/fetched, its missing the items like these

 <torrent:contentLength>125153743</torrent:contentLength> <torrent:infoHash>212E859FB1BAFEA38BAB91BF3D94BB0DBB0ABFE4</torrent:infoHash> <torrent:magnetURI><![CDATA[magnet:?xt=urn:btih:212E859FB1BAFEA38BAB91BF3D94BB0DBB0ABFE4&dn=titletitle=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce]]></torrent:magnetURI> <torrent:seeds>0</torrent:seeds> <torrent:peers>0</torrent:peers> <torrent:verified>1</torrent:verified> <torrent:fileName>fileName.torrent</torrent:fileName> <torrent:fileName>wwe.payback.2015.ppv.hdtv.x264.champions.rarbg.torrent</torrent:fileName> 

how can i get values from these elements too ?


ref: Parsing a XML file using simplexml_load_file return empty object

i have tried this method from above url , by specifying the namespace.

<?php $raw_array = simplexml_load_file('https://kickass.to/new/rss/', null, null, 'torrent', true); print_r($raw_array); ?> 

but it gives empty object

SimpleXMLElement Object ( ) 

So how can i get all the elements from this RSS FEED, i can think of other way is fetching the feed using PHP curl and doing preg_match to find tags and their inside values, but it would be ugly fix.

2
  • 1
    possible duplicate of Parse XML with Namespace using SimpleXML Commented May 18, 2015 at 20:39
  • 1
    see answer with children()-method in the above post. Commented May 18, 2015 at 20:40

0