Random Post: Which One is Better?
RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About Me
  • My Publications
  • My Work Domain
  • phpResource Feeds
  •  

    Some Usage Examples of My XmlToArray Class

    July 4th, 2007

    I am very happy that my XmlToArray Class at PHPClasses.Org got a huge popularity. This class parses XML and forms array from the hierarchical XML format. You can download it from here:

    http://www.phpclasses.org/browse/package/2938.html

    Recently few users requested me to provide a real-life example usage of my class. In this regard, I want to show two examples here:

    BBC News Feed : http://www.rupom.com/demos/bbc/

    Cricinfo Latest : http://www.rupom.com/demos/cricinfo/

    Screenshot of XmlToArray Usage Example
    I want to share my usage.php that I used for BBC News Feed. Here it is:

    ————————-

    require(“XmlToArray.class.php”);
    // Retrieving the RSS first. I used file_get_contents(), you can retrieve by any other way
    $xml_data = file_get_contents(“http://newsrss.bbc.co.uk/rss/ newsonline_world_edition/front_page/rss.xml”);

    //Creating Instance of the Class
    $xmlObj = new XmlToArray($xml_data);

    //Creating Array
    $arrayData = $xmlObj->createArray();

    $rssData = array();
    //getting the feed items
    $rssData = $arrayData[‘rss’][‘channel’][0][‘item’];

    // data is available; loop through the data

    foreach($rssData as $i=>$v)
    {

    $title = $v[‘title’];
    $link = $v[‘link’];
    $category = $v[‘category’];
    $pubDate = $v[‘pubDate’];
    $desc = $v[‘description’];

    /* print data now
    ….
    …..
    …..
    */
    }

    ————————-

    Isn’t this the simplest script? Yes, I tried to make it as simple as possible. Please feel free to let me know more queries.

    Best regards.

    Rupom


    phpBB Topic Map

    July 1st, 2007

    Few months back, I worked on “phpBB topic map” for one of my good friends. It’s a new kind of site map (in this case I called “topic map”). I just want to show you the new kind mapping stuff. You can see the working version here:

    http://forums.dlsoftware.net/sitemap/

    phpBB Topic Map

    If you mouse over any link, you will see OVERLIB functios here. The forum->topic hierarchy has been derived in conventional way (as per phpBB’s database structure). There is nothing special here except the new idea of mapping phpBB topics with a flavor of OVERLIB.

    Please feel free to contact me for any helps.

    Best regards.

    $Rupom