ASP XML解析 [英] Asp XML Parsing

查看:623
本文介绍了ASP XML解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的ASP和在未来几天最后期限。
我收到下面的XML从web服务响应中。

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?

任何帮助是极大AP preciated

Any help is greatly appreciated

谢谢
达米安

在更多的分析,还可以返回一些肥皂的东西作为aboce响应来自Web服务调用。我还可以使用卢克斯code以下?

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.

盗窃卢克为目的聚集优秀的回复:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆