SimpleXML Example II
simplexml2.php:
<?php 
//load xml
$books simplexml_load_file('examples/books.xml');
//loop through the books
foreach ($books->book as $book) { 

        
printf("Title: %s\n"$book->title); 
        
printf("Year: %s\n"$book->year);
        
//get an attribute
        
printf("ISBN:" $book["isbn"] ."\n");
        
//namespaced element do not work..
        
print ("Subject: "$book->subject ."\n");
        
//but with ->children() they do
        
foreach( $book->children("http://purl.org/dc/elements/1.1/") as $child){
            print(
"Subject: "$child ."\n");
        }
        
        print 
"----\n";

?> 

 
SimpleXML Example © copyright 2004  Bitflux GmbH