从xmlnode:name中提取属性值 [英] Extract attribute values from xmlnode:name

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

问题描述

我无法弄清楚如何从下面的XML文件中获取属性值。



此XML输出来自我无法控制的系统

但我需要为客户解析它。



ie,我如何获得'periodBeginDate'的价值?



'< pd:categorypd>

'< vs:period sysid =1

'periodType = daypart

'name =SHIFT

'periodSeqNum =972

'periodBeginDate =2018-11-05T23:59: 06-07:00

'periodEndDate =2018-11-06T23:59:06-07:00/>

'< vs:site> 1

'。

'。

'。

'



提前致谢!



我的尝试:



我用Google搜索'vb.net获取Xmlnode:名称属性

以各种形式但是显示的示例并不是
处理包含带有名称的':'的节点的形式。

I can't figure out how to get the attribute values from the XML file below.

This XML output is from a system I have no control over
but am required to parse it for the customer.

i.e., How would I get the value of 'periodBeginDate'?

' <pd:categorypd>
' <vs:period sysid="1"
' periodType="daypart"
' name="SHIFT"
' periodSeqNum="972"
' periodBeginDate="2018-11-05T23:59:06-07:00"
' periodEndDate="2018-11-06T23:59:06-07:00"/>
' <vs:site>1
' .
' .
' .
'

Thanks in advance!

What I have tried:

I've Googled 'vb.net get Xmlnode:name attributes
in various forms but the examples shown don't
address the form of node that contains a ':' with a name after it.

推荐答案

谢谢对你的回复。

这个有效。我正在继续。

Thanks for your response.
This works. I'm moving on.
Dim root As XmlNode = XMLdoc.DocumentElement
        With root
            For i As Integer = 0 To .ChildNodes.Count - 1
                Select Case .ChildNodes.Item(i).Name
                    Case "vs:period"
                        Debug.Print(.ChildNodes.Item(i).Attributes("periodBeginDate").Value.ToString)
                        Exit For
                End Select
            Next
        End With


这篇关于从xmlnode:name中提取属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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