Artman
12-12-2006, 02:50 PM
Hi,
I'm trying to do a little project in Ajax, but as I am not a JS programmer, I need a little help.
I can successfully send request to my php script, and pass all variables. The php script simply selects some values from books database, and return simple xml document. For each book there's a title and author elements.
If it returns one book, it is easy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book>
<title>Some title...</title>
<author>Some author...</author>
</book>
Now it is easy to retrieve values of title and author by using
getElementsByTagName("title")[0].firstChild.nodeValue;
getElementsByTagName("author")[0].firstChild.nodeValue;
Now, what I don't understand is, what should I do if I end up with xml doc containing more than one book element?
I'd like to have a list like this:
Title
Author
Title
Author
and so on...
Thank you.
Artman
I'm trying to do a little project in Ajax, but as I am not a JS programmer, I need a little help.
I can successfully send request to my php script, and pass all variables. The php script simply selects some values from books database, and return simple xml document. For each book there's a title and author elements.
If it returns one book, it is easy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<book>
<title>Some title...</title>
<author>Some author...</author>
</book>
Now it is easy to retrieve values of title and author by using
getElementsByTagName("title")[0].firstChild.nodeValue;
getElementsByTagName("author")[0].firstChild.nodeValue;
Now, what I don't understand is, what should I do if I end up with xml doc containing more than one book element?
I'd like to have a list like this:
Title
Author
Title
Author
and so on...
Thank you.
Artman