Hi, Rather new to MSXML4. I am parsing an XML data-stream over HTTP,
and would like to know why I cannot parse XML nodes with multiple
parameters.
The XML and Code are below, BUT I would like to know how to parse
individual XML nodes when tags are specified as
"<FIELD NAME="collection">myVal........".
The code below gives me "FIELD" as the value of the XML, not myVal.
All the examples I have found use "<COLLECTION>......." only (without
the parameter).
Some sample code would be good. :)
thanks
Miles.
Sample XML
----
- <RESULTSET FIRSTHIT="1" LASTHIT="10" HITS="10" TOTALHITS="24"
MAXRANK="7909" TIME="0.0780">
- <HIT NO="1" RANK="1908" SITEID="0" MOREHITS="0">
<FIELD NAME="rank">1908</FIELD>
<FIELD
NAME="docid">c42c797ceb8fc321d762335cb4028b42-deployertest</FIELD>
<FIELD NAME="collection">collection test</FIELD>
<FIELD NAME="title">test content- Content</FIELD>
<FIELD NAME="description">test description</FIELD>
</HIT>
[snip]
----
Sample Code
----
<%@ Language="VBScript" %>
<html lang="en">
<head>
<title>Some feeds</title>
<script runat="server" language="VBScript">
Sub OutputFeed ()
Dim returnString
Dim myXML
Dim SoapRequest
Dim SoapURL
Dim myQuery
Dim Loaded
Set SoapRequest = Server.CreateObject("MSXML2.XMLHTTP")
Set myXML =Server.CreateObject("MSXML.DOMDocument")
myXML.Async=False
SoapURL = "http://server/search?query=crime"
SoapRequest.Open "GET",SoapURL , False
SoapRequest.Send()
Loaded = myXML.load(SoapRequest.responseXML)
If Loaded Then
Dim Items, Item, Title, Link, Description, TitleText,
DescriptionText, LinkURL
Set Items = myXML.documentElement.selectNodes("//HIT")
Response.Write "<p>Feed from " & SoapURL & " has currently " &
Items.Length & " items.</p>" & VbCrLf
Response.Write "<ul>" & VbCrLf
For Each Item in Items
Set Title = Item.selectSingleNode("title")
If Title Is Nothing Then
TitleText = ""
Else
TitleText = Title.text
End If
Set Link = Item.selectSingleNode("teaser")
If Link Is Nothing Then
LinkURL = ""
Else
LinkURL = Trim(Link.data)
End If
Set Description = Item.selectSingleNode("description")
If Description Is Nothing Then
DescriptionText = ""
Else
DescriptionText = Description.data
End If
Response.Write "<li><a href=""" & LinkURL & """>" & TitleText & ": "
& DescriptionText & "</a></li>" & VbCrLf
Next
Response.Write "</ul>" & VbCrLf
End If
End Sub
</script>
</head>
<body>
<h1>Some feeds</h1>
<%
OutputFeed()
%>
</body>
</html>
----