简体   繁体   English

扫描VB.NET中的XML数据条目

[英]Scan XML data entries in VB.NET

I have some XML data which I need to inspect in order to pass through to a VB .NET form I am constructing. 我有一些XML数据需要检查,以便传递到我正在构建的VB .NET表单中。 Sample of the XML document below 下面的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"/>

I specifically want to extract the data for the <presenceMap> attribute, but I want to read through each line individually. 我特别想提取<presenceMap>属性的数据,但是我想逐一阅读每一行。 When I currently read this out using the following code, I update a label attribute which dumps all of the elements beginning with "presenceMapping icStatus" into a multi lined label. 当前,我使用以下代码进行读取时,我更新了label属性,该属性将所有以“ presenceMapping icStatus”开头的元素转储到多行标签中。 The end game here is to be able to loop through each of these lines and decide exactly what needs to be displayed but I cant seem to get to grips with the basic task first. 这里的最终游戏是要能够循环浏览每条线,并准确确定需要显示的内容,但是我似乎无法先解决基本任务。 Below is the code I am using currently. 以下是我当前正在使用的代码。

    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

Any hints greatly appreciated. 任何提示,不胜感激。

Here is the syntax try this. 这是语法,请尝试此。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM