XML in ASP

Well, althought using ASP to access XML is a disaster, there are still chances to use it. 

result = false
set mobjDoc =  Server.CreateObject("MSXML2.DOMDocument.3.0")
set mobjHTTP = Server.CreateObject("MSXML2.ServerXMLHttp.3.0")

url = "http://www.test.com/test.asp"
url = url & "?param1=1" 
url = url & "&param2=2"
'response.write url
'response.End()

call mobjHTTP.open("GET", url, false)
mobjHTTP.send()
set mobjDoc = mobjHTTP.responseXML

set currNode = mobjDoc.selectSingleNode("//member")
error_code = currNode.selectSingleNode("//errorcode").text
if error_code = "" then
	result = cLng(currNode.selectSingleNode("//successpointsum").text)
else
	error_str = currNode.selectSingleNode("//errmsg").text
end if

 

Get nodes: dom.selectNodes("/root/person[@dept=’sales’]/name")

Get attributes: node.getAttribute("name")

There are some good pratical examples in this post:

http://blog.yam.com/csylvia/article/4253430

One thought on “XML in ASP

  1. I leave a comment when I especially enjoy a post on a blog or I have something to add to the conversation.
    It is a result of the passion communicated in the article I read.
    And after this article XML in ASP | Rex’s Personal Site. I was moved enough to post a leave a responsea response 😉 I actually do have a few questions for you if it’s
    allright. Could it be simply me or do a few of the comments come
    across as if they are left by brain dead people?
    😛 And, if you are posting at additional online sites, I would
    like to follow you. Could you make a list every one of your public pages like your Facebook page, twitter feed, or linkedin profile?

Comments are closed.