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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp page trying display xml

Status
Not open for further replies.

jojo79

Programmer
Oct 11, 2006
40
US
Does anyone see anything wrong with this? I can not get anything to display. Any help would be great or some sort of direction. Thank You


Code:
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<%
response.expires=-1
q=request.querystring("q")

set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(Server.MapPath("ids.xml"))

set nodes=xmlDoc.selectNodes("CATALOG/SONG[ID='" & q & "']")

for each x in nodes
  for each y in x.childnodes
    response.write("<b>" & y.nodename & ":</b> ")
    response.write(y.text)
    response.write("<br />")
  next
next
%>
</body>
</html>
 
If you do not show the structure of the xml, nobody can show you the solution.

[1]
>set nodes=xmlDoc.selectNodes("CATALOG/SONG[ID='" & q & "']")
By itself, it is fine. It returns something only if the xml is this (CATALOG is root, ID is a child of SONG).
[tt]
<CATALOG>
<SONG>
<ID>some-q-text</ID>
<other-tags>some structure<other-tags>
</SONG>
<!-- etc... -->
</CATALOG>
[/tt]
[2] Leading guesses are these.
[2.1] Your id is in fact an attribute. Then it is this.
[tt]set nodes=xmlDoc.selectNodes("CATALOG/SONG[[red]@[/red]ID='" & q & "']")[/tt]
[2.2] Your CATALOG is not the root, but ID is child of SONG.
[tt]set nodes=xmlDoc.selectNodes("[red]//[/red]CATALOG/SONG[ID='" & q & "']")[/tt]
[2.3] Your CATALOG is not the root, and ID is attribute of SONG.
[tt]set nodes=xmlDoc.selectNodes("[red]//[/red]CATALOG/SONG[[red]@[/red]ID='" & q & "']")[/tt]

ps: Cross-post is generally not appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top