Hi guys. Okay, well I've been at this for a while and I cannot seem to figure it out. Basically, I have a simpleXML PHP file that I'm trying to"parse" (I guess it's called). All I want to do is get some info from an API XML site and display it on my site.

Anyways, I have this code and my page is blank. Please help?

<?php
$html = "";
$url = "http://isbndb.com/api/books.xml?access_key=MCIJARNT&index1=isbn&value1=9780439023528";
$xml = simplexml_load_file($url);
for($i = 0; $i < 10; $i++){

    $title = $xml->Title[$i];
    $html .= "<h1>$title</h1>";

}
echo $html;
?>
Member Avatar for diafol
$html = "";
$url = "http://isbndb.com/api/books.xml?access_key=MCIJARNT&index1=isbn&value1=9780439023528";
$xml = simplexml_load_file($url);
//for($i = 0; $i < 10; $i++){
    echo $xml->BookList->BookData->Title;
//}
echo $html;

there's only one entry

commented: Thanks!! :) +0

Try:

<?php
$html = "";
$url = "http://isbndb.com/api/books.xml?access_key=MCIJARNT&index1=isbn&value1=9780439023528";
$xml = simplexml_load_file($url);

foreach($xml->BookList as $book)
{
    $html .= '<h1>'. $book->BookData->Title .'</h1>';
}

echo $html.PHP_EOL;
?>
Member Avatar for diafol

Your form can have a txtbox called isbn, sent by post.
You pick up the data in $_POST['isbn']

$url = "http://isbndb.com/api/books.xml?access_key=MCIJARNT&index1=isbn&value1={$_POST['isbn']}";
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.