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="collectio n">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">190 8</FIELD>
<FIELD
NAME="docid">c4 2c797ceb8fc321d 762335cb4028b42-deployertest</FIELD>
<FIELD NAME="collectio n">collectio n test</FIELD>
<FIELD NAME="title">te st content- Content</FIELD>
<FIELD NAME="descripti on">test description</FIELD>
</HIT>
[snip]
----
Sample Code
----
<%@ Language="VBScr ipt" %>
<html lang="en">
<head>
<title>Some feeds</title>
<script runat="server" language="VBScr ipt">
Sub OutputFeed ()
Dim returnString
Dim myXML
Dim SoapRequest
Dim SoapURL
Dim myQuery
Dim Loaded
Set SoapRequest = Server.CreateOb ject("MSXML2.XM LHTTP")
Set myXML =Server.CreateO bject("MSXML.DO MDocument")
myXML.Async=Fal se
SoapURL = "http://server/search?query=cr ime"
SoapRequest.Ope n "GET",SoapU RL , False
SoapRequest.Sen d()
Loaded = myXML.load(Soap Request.respons eXML)
If Loaded Then
Dim Items, Item, Title, Link, Description, TitleText,
DescriptionText , LinkURL
Set Items = myXML.documentE lement.selectNo des("//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.selectSing leNode("title")
If Title Is Nothing Then
TitleText = ""
Else
TitleText = Title.text
End If
Set Link = Item.selectSing leNode("teaser" )
If Link Is Nothing Then
LinkURL = ""
Else
LinkURL = Trim(Link.data)
End If
Set Description = Item.selectSing leNode("descrip tion")
If Description Is Nothing Then
DescriptionText = ""
Else
DescriptionText = Description.dat a
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>
----
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="collectio n">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">190 8</FIELD>
<FIELD
NAME="docid">c4 2c797ceb8fc321d 762335cb4028b42-deployertest</FIELD>
<FIELD NAME="collectio n">collectio n test</FIELD>
<FIELD NAME="title">te st content- Content</FIELD>
<FIELD NAME="descripti on">test description</FIELD>
</HIT>
[snip]
----
Sample Code
----
<%@ Language="VBScr ipt" %>
<html lang="en">
<head>
<title>Some feeds</title>
<script runat="server" language="VBScr ipt">
Sub OutputFeed ()
Dim returnString
Dim myXML
Dim SoapRequest
Dim SoapURL
Dim myQuery
Dim Loaded
Set SoapRequest = Server.CreateOb ject("MSXML2.XM LHTTP")
Set myXML =Server.CreateO bject("MSXML.DO MDocument")
myXML.Async=Fal se
SoapURL = "http://server/search?query=cr ime"
SoapRequest.Ope n "GET",SoapU RL , False
SoapRequest.Sen d()
Loaded = myXML.load(Soap Request.respons eXML)
If Loaded Then
Dim Items, Item, Title, Link, Description, TitleText,
DescriptionText , LinkURL
Set Items = myXML.documentE lement.selectNo des("//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.selectSing leNode("title")
If Title Is Nothing Then
TitleText = ""
Else
TitleText = Title.text
End If
Set Link = Item.selectSing leNode("teaser" )
If Link Is Nothing Then
LinkURL = ""
Else
LinkURL = Trim(Link.data)
End If
Set Description = Item.selectSing leNode("descrip tion")
If Description Is Nothing Then
DescriptionText = ""
Else
DescriptionText = Description.dat a
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>
----