Asp XML 解析 [英] Asp XML Parsing
问题描述
我是 asp 新手,在接下来的几天里有一个截止日期.我从 web 服务响应中收到以下 xml.
I am new to asp and have a deadline in the next few days. i receive the following xml from within a webservice response.
print("<?xml version="1.0" encoding="UTF-8"?>
<user_data>
<execution_status>0</execution_status>
<row_count>1</row_count>
<txn_id>stuetd678</txn_id>
<person_info>
<attribute name="firstname">john</attribute>
<attribute name="lastname">doe</attribute>
<attribute name="emailaddress">john.doe@johnmail.com</attribute>
</person_info>
</user_data>");
我怎样才能把这个xml解析成asp属性?
How can i parse this xml into asp attributes?
非常感谢任何帮助
谢谢达米安
进一步分析,由于 aboce 响应来自 Web 服务调用,因此还会返回一些肥皂内容.我还能用下面的 lukes 代码吗?
On more analysis, some soap stuff is also returned as the aboce response is from a web service call. can i still use lukes code below?
推荐答案
你需要阅读 MSXML 解析器.这是一个好的多合一示例的链接 http://oreilly.com/pub/h/466
You need to read about MSXML parser. Here is a link to a good all-in-one example http://oreilly.com/pub/h/466
阅读 XPath 也会有所帮助.您可以在 MSDN 中获得所需的所有信息.
Some reading on XPath will help as well. You could get all the information you need in MSDN.
从 Luke 窃取代码用于聚合目的的优秀回复:
Stealing the code from Luke excellent reply for aggregation purposes:
Dim oXML, oNode, sKey, sValue
Set oXML = Server.CreateObject("MSXML2.DomDocument.6.0") 'creating the parser object
oXML.LoadXML(sXML) 'loading the XML from the string
For Each oNode In oXML.SelectNodes("/user_data/person_info/attribute")
sKey = oNode.GetAttribute("name")
sValue = oNode.Text
Select Case sKey
Case "execution_status"
... 'do something with the tag value
Case else
... 'unknown tag
End Select
Next
Set oXML = Nothing
这篇关于Asp XML 解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!