Converting an XML data island to 2 arrays
I'm using the following setup.
I've an ASP page that returns XML from an SQL query
<%
Response.ContentType = "text/xml"
...
...
oRS.Save Response, 1
...
%>
This returns beautiful XML in IE6. The data is 2 columns - ReportDate and Value. No problems here. I've a VB6 app which parses this and returns 2 Arrays.
Now I'm trying to turn this XML into 2 arrays but using VBScript in another .htm page. Thus:-
8<----------------
'Set up chart data from XMLIsland
'Extract the contents of the XML Data island and insert it into two
'arrays: one array for the chart categories and one array for the
'chart values.
Dim nCount, nodes, j
Dim xmldoc
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async=false
xmlDoc.loadXML sXMLDSCPath
Set nodes = xmlDoc.childNodes.Item(0).childNodes.Item(1).child Nodes
nCount = nodes.length
Redim aReportDate(nCount)
Redim aValues(nCount)
For j=1 to nCount
aReportDate(j) = Nodes.Item(j - 1).Attributes.Item(0).Text
aValues(j) = Nodes.Item(j - 1).Attributes.Item(1).Text
Next
8<--------------------
Now sXMLDSCPath is returning a corrent link, which contains a corrent, well formatted XML page.
But I get an 'Object required' error for the following line:-
Set nodes = xmlDoc.childNodes.Item(0).childNodes.Item(1).child Nodes
I know this is going to be horribly simple, but I just don't know why it doesn't work in VBScript. I haven't posted the XML (I didn't want to post too much info) but can if required.
any help greatly appreciated.
Neil
P.S. - I know this would fly in .NET, but for various reasons has to be done in old fashioned VBScript in an HTM page.
|