Problem Parsing XML into ASP

A

ayo991

I am having a problem parsing XML into ASP. I have the follow XML
code from a server that reads

"<?xml version="1.0" encoding="UTF-8" ?>
- <ISBNdb server_time="2007-09-13T15:11:08Z">
- <BookList total_results="1" page_size="10" page_number="1"
shown_results="1">
- <BookData book_id="paul_laurence_dunbar_portrait_of_a_poet"
isbn="0766013502">
<Title>Paul Laurence Dunbar</Title>
<TitleLong>Paul Laurence Dunbar: portrait of a poet</TitleLong>
<AuthorsText>Catherine Reef</AuthorsText>
<PublisherText publisher_id="enslow_publishers">Berkeley Heights,
NJ : Enslow Publishers, c2000.</PublisherText>
<Details dewey_decimal="811/.4" physical_description_text="128 p. :
ill. ; 24 cm." language="eng" edition_info=""
dewey_decimal_normalized="811.4" lcc_number="PS1557"
change_time="2005-04-03T07:24:51Z" price_time="2007-09-13T11:53:16Z" /</BookData>
</BookList>
</ISBNdb>"

and here is my code

"<%
Dim xmlDoc
set xmlDoc = createObject("MSXML2.DOMDocument")

xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load("http://XXXX.com//api/books.xml?
access_key=X&results=details&index1=isbn&value1=0766013502")

response.write xmldoc.documentelement.childnodes(0).Text
%>"

that displays

"Paul Laurence Dunbar Paul Laurence Dunbar: portrait of a poet
Catherine Reef Berkeley Heights, NJ : Enslow Publishers, c2000."

The problem that I am having is that I want it to break the xml up
into the individual categories with a response.write. Such as

Title: Paul Laurence Dunbar
Author: Catherine Reef

and so on. I cannot figure out what I need to do to display this
correctly. I have tried to change this

"xmlDoc.selectSingleNode("/SBNdb /BookList/
BootData").Attributes.GetNamedItem("Title").Text "

but I am not having any luck. Any help would be greatly appreciated.
 
A

Anthony Jones

I am having a problem parsing XML into ASP. I have the follow XML
code from a server that reads

"<?xml version="1.0" encoding="UTF-8" ?>
- <ISBNdb server_time="2007-09-13T15:11:08Z">
- <BookList total_results="1" page_size="10" page_number="1"
shown_results="1">
- <BookData book_id="paul_laurence_dunbar_portrait_of_a_poet"
isbn="0766013502">
<Title>Paul Laurence Dunbar</Title>
<TitleLong>Paul Laurence Dunbar: portrait of a poet</TitleLong>
<AuthorsText>Catherine Reef</AuthorsText>
<PublisherText publisher_id="enslow_publishers">Berkeley Heights,
NJ : Enslow Publishers, c2000.</PublisherText>
<Details dewey_decimal="811/.4" physical_description_text="128 p. :
ill. ; 24 cm." language="eng" edition_info=""
dewey_decimal_normalized="811.4" lcc_number="PS1557"
change_time="2005-04-03T07:24:51Z" price_time="2007-09-13T11:53:16Z" /
</BookData>
</BookList>
</ISBNdb>"

and here is my code

"<%
Dim xmlDoc
set xmlDoc = createObject("MSXML2.DOMDocument")

xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.load("http://XXXX.com//api/books.xml?
access_key=X&results=details&index1=isbn&value1=0766013502")

response.write xmldoc.documentelement.childnodes(0).Text
%>"

that displays

"Paul Laurence Dunbar Paul Laurence Dunbar: portrait of a poet
Catherine Reef Berkeley Heights, NJ : Enslow Publishers, c2000."

The problem that I am having is that I want it to break the xml up
into the individual categories with a response.write. Such as

Title: Paul Laurence Dunbar
Author: Catherine Reef

and so on. I cannot figure out what I need to do to display this
correctly. I have tried to change this

"xmlDoc.selectSingleNode("/SBNdb /BookList/
BootData").Attributes.GetNamedItem("Title").Text "

but I am not having any luck. Any help would be greatly appreciated.

Title element is not an attribute. id and isbn are examples of attributes.

Dim bookData : Set bookData =
xmlDoc.selectSingleNode("/ISBNdb/BookList/BookData/")
Dim titleLong : Set titleLong = xmlDoc.selectSingleNode("TitleLong")
Dim authorText : Set authorText = xmlDoc.selectSingleNode("AuthorText")

If Not titleLong Is Nothing Response.Write "Title: " & titleLong.text & "<br
/>"
If Not authorText Is Nothing Response.Write "Title: " & authorText .text &
"<br />"
 

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top