Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHttpRequest - nodes question

Status
Not open for further replies.

firsttube

Technical User
Apr 21, 2004
165
CA
I have this server side code that accepts and xml stream from another page:
Code:
Set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
			objXmlHttp.open "GET", url,False
			objXmlHttp.send
			strHTML = objXmlHttp.responseText

			set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
			set nodeList = Server.CreateObject("Microsoft.XMLDOM")
			xmlDoc.loadXML (strHTML)

			Set Root = xmlDoc.documentElement
			Set nodeList = Root.getElementsByTagName("cell")
			Set node = xmlDoc.selectSingleNode("/data/item/cell/")

here is the xml:
Code:
<?xml version="1.0" encoding="UTF-8" ?> 
 <data>
 <item>
  <cell name="ID" value="58261" /> 
  <cell name="field1" value="test" /> 
  <cell name="field2" value="test2" /> 
  <cell name="field3" value="test3" /> 
</item>
</data>

I want to write out all the names and values of all the cell nodes. Something like:
Code:
For each node in nodelist
 response.write(node.Name & " " & node.value)

next

how can I go about doing this?
thanks
ft


Information is not Knowledge, Knowledge is not Wisdom, Wisdom is not Truth, Truth is not Beauty, Beauty is not Love, Love is not Music, Music is the best.
 
[tt]Set Root = xmlDoc.documentElement
[red]'[/red]Set nodeList = Root.getElementsByTagName("cell")
[blue]Set nodeList = Root.selectNodes("item/cell")[/blue]
[red]'[/red]Set node = xmlDoc.selectSingleNode("/data/item/cell/")
For each node in nodelist
response.write(node.[red]getAttribute("[/red]Name[red]")[/red] & " " & node.[red]getAttribute("[/red]value[red]")[/red])
next
[/tt]
 
Amendment
The corresponding line should be read like this.
[tt] response.write(node.getAttribute("[red]n[/red]ame") & " " & node.getAttribute("value"))[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top