在 vbnet 中从 XML 中获取值 [英] get value from XML in vbnet

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

问题描述

我是使用 vbnet 的网络服务应用程序的新手.服务返回的值采用 XML 格式.

I'm new in web service app using vbnet. the value return from service is in XML format.

<NewDataSet>
  <Table> 
    <Symbol>Fe</Symbol>
  </Table>
</NewDataSet>

如何在不将其写入文本文件的情况下检索该值.我知道有一个命名空间 SYSTEM.XML 但我不熟悉它的类:(

How can I retrieve the value without writing it into text file. I know there's a namespace SYSTEM.XML but I'm not familiar with its classes :(

推荐答案

假设您的 Web 服务调用为您提供字符串形式的 XML.

Let's assume that your web service call gives you that XML in a string.

Dim MyXml as String = YourWebService.GetXml()

如果你想获得Symbol"标签的值,你可以这样做...

If you want to get the value of the "Symbol" tag, you could do this...

Dim MyDoc as New System.Xml.XmlDocument
MyDoc.LoadXml(MyXml)
dim SymbolText as String = MyDoc.SelectSingleNode("//NewDataSet/Table/Symbol").InnerText

希望这会有所帮助!

这篇关于在 vbnet 中从 XML 中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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