【发布时间】:2015-02-15 10:56:48
【问题描述】:
我在将一些 XML 信息解析到富文本框中时遇到了一些困难。我正在从流中提取 XML 文件,并且数据成功通过,但是当我尝试查看元素时,我认为有问题。
这是流加载后的sn-p(通常每个表单名称旁边都有值)
"
"我的最终目标是能够获取 SupportRepKey 和 SupportRepName。
我认为问题在于 下的每个名称都没有被归类为元素。当我运行这样的代码来尝试获取“SupportRepKey”的值时,消息框将显示一个空值(空白)。
Dim reader As XDocument = XDocument.Load(dataStream)
For Each detail As XElement In reader...<details>
Dim APIKey As String = detail.Element("SupportRepKey")
MessageBox.Show(APIKey) 'returns null value
Next
如果我用这个运行它(用于故障排除以确保从数据流中提取 XML 文件):
Dim reader As XDocument = XDocument.Load(dataStream)
For Each detail As XElement In reader...<details>
MessageBox.Show(detail.Value) 'returns all values in one long string
Next
它在一个长字符串中返回每个
【问题讨论】:
标签: xml vb.net parsing httpresponse