Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Friday, January 7, 2011

Introducing Web 2.0 concepts

Important Web 2.0 concept

Wednesday, December 8, 2010

Using PHP simple script that parses XML to HTML code for anyone who needs to put weather forecast on their websites

Using PHP simple script that parses XML to HTML code for anyone who needs to put weather forecast on their websites
<?php
$xml = simplexml_load_file("http://www.google.com/ig/api?weather=milan");
$day=array();
$low=array();
$high=array();
$icon=array();
$condition =array();
$humidity=array();
$wind_condition=array();
$googlePath="http://www.google.com";

 foreach($xml->children() as $child)
 {
   
     foreach($child->children() as $schild)
          {
                 
                if($schild->getName()!=" ")
                {
                    if( $schild->getName()=="forecast_conditions")
                    {
               
                        foreach($schild->children() as $sschild)
                          {
                             
                                if( $sschild->getName()=="day_of_week")
                                {
                                    $day[]= $sschild['data'];
                                }
                                if( $sschild->getName()=="low")
                                {
                                    $low[]= $sschild['data'];
                                }
                                if( $sschild->getName()=="high")
                                {
                                    $high[]= $sschild['data'];
                                }
                                if( $sschild->getName()=="icon")
                                {
                                    $icon[]= $sschild['data'];
                                }
                                if( $sschild->getName()=="condition")
                                {
                                    $condition[]= $sschild['data'];
                                }
                               
                          }
                    }
                   
                    if( $schild->getName()=="current_conditions")
                    {
                        foreach($schild->children() as $sschild)
                          {
                              if( $sschild->getName()=="humidity")
                                {
                                    $humidity= $sschild['data'];
                                }
                               
                              if( $sschild->getName()=="wind_condition")
                                {
                                    $wind_condition = $sschild['data'];
                                }
                          }
                         
                    }
                   
                }

         
         
          }
   
 }



?>