This may seem too trivial but I have tried all possible methods
- async=true (onreadystatechange)
- async=false (xmlhttp open)
source http://ift.tt/ZxhTtu
3.xmlhttp.open("GET","http://"+location.host+"/cd_catalog.xml",false)
source
Open XML and display data in div
basically what I want is for javascript and xml in the same folder and use javascript to return values.
The actual program I am working on:
var xmlSolver = function MakeXmlSolver(){};
xmlSolver.GetAllAuthorsInStock()=function()
{
var author=xmlDoc.getElementsByTagName
("author").childNodes.nodeValue;
return author;
};
xmlSolver.GetAllBooksInStock()=function()
{
var title=xmlDoc.getElementsByTagName
("title").childNodes.nodeValue;
}
and the xml
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookCollection>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<firstName>Benjamin</firstName>
<lastName>Franklin</lastName>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<firstName>Herman</firstName>
<lastName>Melville</lastName>
</author>
<price>11.99</price>
</book>
<book genre="novel" publicationdate="2002" ISBN="0-201-63361-2">
<title>Oryx and Crake</title>
<author>
<firstName>Margaret</firstName>
<lastName>Atwood</lastName>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Republic</title>
<author>
<name>Plato</name>
</author>
<price>7.99</price>
</book>
</bookCollection>
Aucun commentaire:
Enregistrer un commentaire