[thelist] beginner XML ASP question
Duncan O'Neill
dbaxo at ihug.co.nz
Tue Oct 1 10:12:00 CDT 2002
Jacques Capesius wrote:
> see, I told you it was something stupid I was doing. Well, taking lon's much
> appreciated advice, I reformatted the xml document as follows.
>
> <?xml version="1.0"?>
> <articles>
> <webObject>
> <IDNo>1</IDNo>
> <Title>How to code in XML</Title>
> <Subject>XML</Subject>
> <keywords>XML Code</keywords>
> <content>Don't bother. It's too difficult.</content>
> </webObject>
> </articles>
>
> ...and I changed the code around to access it a little, so that it looks
> like this.
>
> Dim xml,root,i
> set xml = Server.CreateObject("Microsoft.XMLDOM")
> xml.async = False
> xml.load (Server.MapPath("test.xml"))
> set root = xml.documentElement
> For i = 0 To (root.childNodes.length)
> document.write(root.childNodes.item(i).text & "<br>")
> Next
>
> ... still, the root.childNodes.length throws an "object required" error.
> I'll continue to look into this, but any nudge in the right direction
would
> be most appreciated. Thanks again, fellaz.
The XML doc is (now) fine, but you're .asp code is awry
here. I hope it helps you in future if I point them
out.
1) the 'for' line: zero-based indexes not supported.
2) You don't need to use 'item(i)', which is a js
notation, just childNodes and the index, as in
childNodes(i)
I've posted the asp file with fixes below, which
worked for me with well-formed XML docs.
<%
Dim xml,root,i
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("testing_list_qu.xml"))
set root = xml.documentElement
For i = 1 To (root.childNodes.length)
response.write(root.childNodes(i-1).text & "<br>")
Next
%>
hth,
--
Duncan O'Neill
The Urban Legend magazine
http://homepages.ihug.co.nz/~dbaxo/
More information about the thelist
mailing list