hi i am trying to collect the database of books from the devloper area
of isbndb.com. this site provide us a passkey with the help of that we can collect the xml data from database depending upon criterias.

.http://isbndb.com/api/books.xml?access_key=6XEB6RTL&index1=publisher_id&value1=oreilly
this link collect the xml data of books publisher of oreilly.

then i use php code
like

<?php 
            $requestAddress = "http://isbndb.com/api/books.xml?access_key=6XEB6RTL&index1=publisher_id&value1=oreilly"; 
    $xml_str = file_get_contents($requestAddress,0);
    print "<br />$xml_str<br />";

?>

to fetch xml data as text format.
my problem is that this fetch data is like a paragraph,and very tough to distinguish the records.

please help me to change this php code so the data is look like records.
or if possible is there is any way to use those data directly to tha database??????

Recommended Answers

All 3 Replies

Use SAX or DOM php api.

hi thanks for reply.
but i am a beginner in php.so it is very herd to understand for me with out examples.
plz give me some example description .
plz help me...

I presume that the content of xml file stored in $xml_str would be like this :

<?xml version="1.0" ...>
  <Students>
    <Record No="1">
      <Name>Mr.X</Name>
      <GrNo>11</GrNo>
   </Record>
   ....
 </Students>
<?php 
       $requestAddress = "http://isbndb.com/api/books.xml? 
                   access_key=6XEB6RTL&index1=publisher_id&value1
                                    =oreilly"; 
    $xml_str = file_get_contents($requestAddress,0);
    print "<br />$xml_str<br />";

   $s = simplexml_load_string($xml_str);
  print $s->Record->Name;
  print $s->Record->GrNo;
  print $s->Record["No"]; // Attribute

  foreach($s as $rec) {
    print "<br/>" . $rec[0] .  '   '  .  $rec[1]
 }
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.