XML Parsing Error: not well-formed
Location: http://localhost/rea...e&submit=Search
Line Number 1, Column 11:biblebible<?xml version="1.0" encoding="UTF-8"?>
Javascript code:
var titlesArray = new Array();
function handleAjaxResponse(e) {
'use strict';
if(typeof e == 'undefined') e = window.event;
var ajax = e.target || e.srcElement;
//console.log(ajax);
if(ajax.readyState == 4 ) {
if ((ajax.status >=200 && ajax.status < 300) || ajax.status == 304) {
console.log(ajax.responseXML);
if(ajax.responseXML) {
console.log(ajax.responseXML);
var allBooks = ajax.responseXML.getElementsByTagName('BookData');
for(var i=0, count = allBooks.length; i<count; i++) {
titlesArray[i] = allBooks[i].getElementsByTagName('Title')[0].firstChild;
console.log(titlesArray[i]);
}
}
}
}
}
function sendValue() {
var searchTerm = document.getElementById('searchTerm');
console.log(searchTerm.value);
var ajax = getXMLHttpRequestObject();
ajax.onreadystatechange = handleAjaxResponse;
ajax.open('GET', 'isbn3.php?searchterm=' + encodeURIComponent(searchTerm.value), true);
//ajax.open('GET', './isbn3.php', true);
ajax.send(null);
// return false;
}
window.onload = function() {
'use strict';
document.getElementById('searchTerm').onkeyup = sendValue;
}
code for isbn3.php:
if(isset($_GET['searchterm']) && is_string($_GET['searchterm']))
{
//Hold the serachterm into a variable, and typecast it.:
$isbnQuery =(string) $_GET['searchterm'];
if($isbnQuery == NULL)
{
$error[] = "You forgot to enter ISBN. Please go back and correct the error.";
}
if(empty($error))
{
$isbnData ="http://isbndb.com/api/books.xml?access_key=keyno&results=details,texts&index1=title&value1=$isbnQuery";
//$xmlData = @simplexml_load_file($isbnData); //or die("Invalid ISBN ERROR");
$xmlDoc = file_get_contents($isbnData);
//echo '<?xml version="1.0" encoding="utf-8" standalone="yes">';
header("Content-Type: application/xml");
echo $xmlDoc; //Read the entire xml document in string.
?>
xml file is as : http://isbndb.com/data-intro.html

New Topic/Question
Reply



MultiQuote




|