[英]Scan XML data entries in VB.NET
我有一些XML数据需要检查,以便传递到我正在构建的VB .NET表单中。 下面的XML文档样本
<icIntegrationConfiguration>
<icServer hostname="icserver" username="icadmin" password="1234" useNtAuth="false"/>
<lyncFarm ucmaAppId="InteractionCenterLyncIntegrationService" ucmaUserAgent="icUcmaUser" ucmaAppName="InteractionCenterLyncIntegrationService" ucmaVersion="3"/>
<profiles>
<!-- Enterprise Voice synchronizes only if an Interaction Center client is logged in. -->
<profile scope="Global" qualifier="EnterpriseVoice">
<augmentationConfigurations>
<augmentationConfiguration name="Default" order="1" enableIcToLyncSync="true" enableLyncToIcSync="true" addInQueueText="true">
<conditions>
<condition name="UserState">
<qualifications>
<qualification argument="LoggedInToClient" value="True"/>
</qualifications>
</condition>
<condition name="UserType">
<qualifications>
<qualification argument="EnterpriseVoice" value="True"/>
</qualifications>
</condition>
</conditions>
<presenceMap>
<presenceMapping icStatus="Available" lyncPresenceFromIc="3500" direction="TwoWay"/>
<presenceMapping icStatus="Available, Follow-Me" lyncPresenceFromIc="3500" direction="TwoWay"/>
<presenceMapping icStatus="Available, Forward" lyncPresenceFromIc="3500" direction="TwoWay"/>
<presenceMapping icStatus="Available, No ACD" lyncPresenceFromIc="3500" direction="TwoWay"/>
我特别想提取<presenceMap>
属性的数据,但是我想逐一阅读每一行。 当前,我使用以下代码进行读取时,我更新了label属性,该属性将所有以“ presenceMapping icStatus”开头的元素转储到多行标签中。 这里的最终游戏是要能够循环浏览每条线,并准确确定需要显示的内容,但是我似乎无法先解决基本任务。 以下是我当前正在使用的代码。
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnLoad.Click
If (System.IO.File.Exists(txtPath.Text.ToString())) Then
Dim document As XmlReader = New XmlTextReader(txtPath.Text.ToString())
While (document.Read())
Dim type = document.NodeType
If (type = XmlNodeType.Element) Then
If (document.Name = "presenceMap") Then
xmlLync1.Visible = True
xmlLync1.Text = document.ReadInnerXml.ToString()
End If
End If
End While
Else
MessageBox.Show("The filename you selected was not found.")
End If
任何提示,不胜感激。
这是语法,请尝试此。
Dim Nodes As XmlNodeList = YourXMLDocument.DocumentElement.SelectNodes("/ParentNode/ChildNode")
For Each node As XmlNode In Nodes
If node.Attributes("YourNodeName").Value = Something
Do stuff
End if
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.