Simple XML : simplexml_load_string « XML « PHP






Simple XML

 
<html><head><title>SimpleXML</title></head><body>

<?php

echo( "<table>" );

$sx = simplexml_load_file( "books.xml" );
foreach( $sx -> title as $title )
{  
  echo( "<tr>" );
  echo( "<td align='right'>" );
  echo( "<img src='" . $title -> pic . "'>" );
  echo( "</td>" );
  echo( "<td valign='top'>" );
  echo( "<b>"  . $title -> topic . "</b>" ); 
  echo( "<br>" . $title -> series );
  echo( "</td>" );
  echo( "</tr>" );
}
echo( "</table>" );

?>
 
</body></html>
  
  








Related examples in the same category

1.Accessing identically named elements
2.Adding attributes
3.Changing elements and attributes
4.Loop through children
5.Loading an XML document from a file
6.Fetching a remote XML document
7.Parsing XML in a string
8.Parsing an XML Document with SimpleXML
9.simplexml_load_file.php
10.Loading a remote XML document
11.Outputting XML
12.Using SimpleXML to extract data
13.Print XML element attributes
14.Printing sub-element contents
15.Saving an XML document to a file