[Help] Embedding XML Data On Your Site

Discussion in 'HTML & Website Design' started by Shawon, May 21, 2009.

  1. #1
    I'm not too familiar with XML and RSS feeds and stuff, I had a question about how to embed XML data on a site.

    The XML I'm trying to embed is here (XML Format For Daily Prayer Times): http://www.islamicfinder.org/prayer...ate=NY&zipcode=&country=usa&calculate=1&lang=

    It says this is the XML code:
    http://www.islamicfinder.org/prayer_service.php?country=usa&city=new_york&state=NY&zipcode=&latitude=40.7500&longitude=-73.9967&timezone=-5.0&HanfiShafi=1&pmethod=5&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml
    Code (markup):
    Says this is how the result is gonna be: http://www.islamicfinder.org/prayer...maghribInterval=1&dayLight=1&simpleFormat=xml


    So I'm wondering if someone can help me embed that on a HTML page. Like what code would I use to make it read the XML source and then what code would I put in the areas where I want the XML data to be output?

    I searched around Google found a few methods but I'm not sure if I did something wrong but it wasn't working right.
     
    Shawon, May 21, 2009 IP
  2. Shawon

    Shawon Well-Known Member

    Messages:
    291
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #2
    Anyone have an idea?
     
    Shawon, May 22, 2009 IP
  3. Spawny

    Spawny Well-Known Member

    Messages:
    252
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #3
    well you can use php to retrieve those data in that xml file try this for example

    
    <?php
    $data = file_get_contents('http://www.islamicfinder.org/prayer_service.php?country=usa&city=new_york&state=NY&zipcode=&latitude=40.7500&longitude=-73.9967&timezone=-5.0&HanfiShafi=1&pmethod=5&fajrTwilight1=&fajrTwilight2=&ishaTwilight=0&ishaInterval=0&dhuhrInterval=1&maghribInterval=1&dayLight=1&simpleFormat=xml');
    $xml  = new SimpleXMLElement($data); 
    
    //see whats in the xml
    print '<pre>';
    print_r($xml);
    print '</pre>';
    
    
    //print individually
    echo "fajr value is ". $xml -> fajr ."</br>" ;
    echo "sunrise value is ". $xml -> sunrise ."</br>" ;
    echo "dhuhr value is ". $xml -> dhuhr ."</br>" ;
    echo "asr value is ". $xml -> asr."</br>" ;
    
    //and so on...
    ?>
    
    PHP:
     
    Spawny, May 22, 2009 IP
  4. Shawon

    Shawon Well-Known Member

    Messages:
    291
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #4
    worked perfect, thanks alot
     
    Shawon, May 22, 2009 IP