[英]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.