7
Contributors
8
Replies
50
Views
5 Years
Discussion Span
Last Post by Andrew_24
2

I found a sample XML file by searching. So I wrote a small php code to read it. I hope this example will help you.

<?php
    // Loading the XML file
    $xml = simplexml_load_file("books.xml");

    echo "<h2>".$xml->getName()."</h2><br />";


    foreach($xml->children() as $book)
    {
        echo "BOOK : ".$book->attributes()->id."<br />";
        echo "Author : ".$book->author." <br />";
        echo "Title : ".$book->title." <br />";
        echo "Genre : ".$book->genre." <br />";
        echo "Price : ".$book->price." <br />";
        echo "Publish Date : ".$book->publish_date." <br />";
        echo "Description : ".$book->description." <br />";
        echo "<hr/>";
    }
?>

This is the format of the XML file I found

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
   <book id="bk102">
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
      <publish_date>2000-12-16</publish_date>
      <description>A former architect battles corporate zombies,
      an evil sorceress, and her own childhood to become queen
      of the world.</description>
   </book>
</catalog>
0

Hi you are very good man thank you lot. thank you again

Edited by pritaeas: Removed skype name.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.