Jeg har et problem med at hente noget data fra en xml fil, kan ikke få det til at virke. Koden er herunder.
kode:
<%
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.setProperty "ServerHTTPRequest", True
If objXMLDoc.load("http://localhost/60.xml") Then
'Normal processing
Else
'Error handling, for example:
Response.Write objXMLDoc.parseError.reason
End If
Set Nodelist = objXMLDoc.documentelement.selectsinglenode("character[@name='Ragnorr']/totalrp")
Response.write Nodelist.text
%>
her er så et stykke af xml filen
<?xml version="1.0" encoding="UTF-8" ?>
- <guild_status>
- <guild name="Nazgul" realm="Midgard" activechars="370" activemembers="128" guildrp="67732934" contacturl="admin@nazgulhq.co.uk" websiteurl="http://www.nazgulhq.net" timestamp="23-09-2004 08:18:07" sshield="http://www.camelot-europe.com/herald/img/shields/5-1-1-full.png" semblem="http://www.camelot-europe.com/herald/img/insignia/n_emblem_035.gif" alliance="147">
- <character name="Ragnorr" laston="Recently">
<race>Norseman</race>
<class>Warrior</class>
<level>50</level>
<guildrank>1</guildrank>
<totalrp>14233</totalrp>
<lastweekrp>0</lastweekrp>
<anon>False</anon>
</character>
</guild>
</guild_status>
Prøv at erstatte
Set Nodelist = objXMLDoc.documentelement.selectsinglenode("character[@name='Ragnorr']/totalrp")
Response.write Nodelist.text
med
Set oNode = objXMLDoc.selectSingleNode("character[@name='Ragnorr']/totalrp")
Response.write oNode.text
- karmazilla -
det funkede ik :/ får stadig denne fejl.
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'oNode'
/test.asp, line 14
ps. ignorer mail
kunne bare ikke finde ud af at besvare denne post heh.