Problem Parsing XML into ASP

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.
ayo991 [ Do, 13 September 2007 17:38 ] [ ID #1819556 ]

Re: Problem Parsing XML into ASP

<ayo991 [at] gmail.com> wrote in message
news:1189697913.485852.65540 [at] 50g2000hsm.googlegroups.com...
> 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 &
"
"



--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones [ Fr, 14 September 2007 09:38 ] [ ID #1820558 ]

Re: Problem Parsing XML into ASP

That answer would take a while to write.

Try this site:
http://msconline.maconstate.edu/tutorials/ASP/default.htm
Very good tutorial.

<ayo991 [at] gmail.com> wrote in message
news:1189697913.485852.65540 [at] 50g2000hsm.googlegroups.com...
>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.
>
jp2code [ Do, 20 September 2007 23:03 ] [ ID #1825224 ]

Re: Problem Parsing XML into ASP

"jp2code" <poojo.com/mail> wrote in message
news:eP3gum8%23HHA.980 [at] TK2MSFTNGP06.phx.gbl...
> That answer would take a while to write.
>
> Try this site:
> http://msconline.maconstate.edu/tutorials/ASP/default.htm
> Very good tutorial.
>

I disagree. I've just taken a look at a couple of the articles and they
leave some significant room for improvement. E.g., CDONTS instead of
CDOSYS and techniques described open to SQL injection attacks.

--
Anthony Jones - MVP ASP/ASP.NET
Anthony Jones [ Fr, 21 September 2007 09:25 ] [ ID #1826260 ]
Webserver » microsoft.public.inetserver.asp.general » Problem Parsing XML into ASP

Vorheriges Thema: Response.Write Date() problems
Nächstes Thema: loosing page breaks