需要检索特定的XML节点值

需要检索特定的XML节点值

本文介绍了需要检索特定的XML节点值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?xml version="1.0"?>
<UITest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="" Id="b35e9ee2-fbe4-4c42-b667-98350a4b7a05" AssemblyVersion="11.0.50727.1" Version="1.0" xmlns="http://schemas.microsoft.com/VisualStudio/TeamTest/UITest/2010">
  <Configuration>
    <Group Name="IE">
      <Setting Name="Version" Value="8.0.7601.17514" WarningLevel="1" />
      <Setting Name="InformationBar" WarningLevel="1" />
      <Setting Name="AutoCompletePassword" Value="no" WarningLevel="1" />
      <Setting Name="AutoCompleteForm" Value="no" WarningLevel="1" />
      <Setting Name="DefaultBrowser" Value="IEXPLORE.EXE" WarningLevel="1" />
      <Setting Name="PopupBlocker" Value="no" WarningLevel="1" />
      <Setting Name="TabbedBrowsing" Value="1" WarningLevel="2" />
      <Setting Name="InternetZoneSecurity" Value="66816" WarningLevel="2" />
      <Setting Name="IntranetZoneSecurity" Value="69632" WarningLevel="2" />
      <Setting Name="TrustedZoneSecurity" Value="70912" WarningLevel="2" />
      <Setting Name="RestrictedZoneSecurity" Value="73728" WarningLevel="2" />
      <Setting Name="PhishingFilter" WarningLevel="1" />
      <Setting Name="EnhancedSecurityConfiguration" WarningLevel="1" />
    </Group>
    <Group Name="OS">
      <Setting Name="Name" Value="Microsoft Windows 7 Enterprise " WarningLevel="2" />
      <Setting Name="Version" Value="Microsoft Windows NT 6.1.7601 Service Pack 1" WarningLevel="2" />
      <Setting Name="IsUserAdmin" Value="False" WarningLevel="2" />
      <Setting Name="Is64BitOperatingSystem" Value="False" WarningLevel="2" />
      <Setting Name="IsTerminalServerSession" Value="False" WarningLevel="2" />
      <Setting Name="OSLanguage" Value="1033" WarningLevel="1" />
      <Setting Name="UserLocale" Value="1033" WarningLevel="1" />
      <Setting Name="DragFullWindows" Value="True" WarningLevel="2" />
      <Setting Name="ScreenResolutionWidth" Value="1366" WarningLevel="2" />
      <Setting Name="ScreenResolutionHeight" Value="768" WarningLevel="2" />
      <Setting Name="SystemDPIX" Value="96" WarningLevel="2" />
      <Setting Name="SystemDPIY" Value="96" WarningLevel="2" />
      <Setting Name="Aero" Value="1" WarningLevel="1" />
      <Setting Name="UACEnabled" Value="1" WarningLevel="2" />
      <Setting Name="UACPromptEnabled" Value="5" WarningLevel="1" />
    </Group>
    <Group Name="TechnologyManagers">
      <Setting Name="Web" WarningLevel="1" />
      <Setting Name="UIA" WarningLevel="1" />
    </Group>
  </Configuration>
  <InitializeActions />
  <ExecuteActions />
  <CleanupActions />
  <OnErrorActions />
  <Maps>
    <UIMap Id="UIMap">
      <TopLevelWindows>
        <TopLevelWindow ControlType="Window" Id="UIVtigerCRM5CommercialWindow" FriendlyName="vtiger CRM 5 - Commercial Open Source CRM - Window..." SpecialControlType="BrowserWindow" SessionId="2820682">
          <TechnologyName>MSAA</TechnologyName>
          <WindowTitles>
            <WindowTitle>vtiger CRM 5 - Commercial Open Source CRM</WindowTitle>
            <WindowTitle>Administrator - Leads - vtiger CRM 5 - Commercial Open Source CRM - Windows Internet Explorer provided by Dell Client Engineeri</WindowTitle>
          </WindowTitles>
          <SearchConfigurations>
            <SearchConfiguration>VisibleOnly</SearchConfiguration>
          </SearchConfigurations>
          <AndCondition Id="SearchCondition">
            <PropertyCondition Name="Name">vtiger CRM 5 - Commercial Open Source CRM</PropertyCondition>
            <PropertyCondition Name="ClassName">IEFrame</PropertyCondition>
            <PropertyCondition Name="ControlType">Window</PropertyCondition>
          </AndCondition>
          <SupportLevel>1</SupportLevel>
          <Descendants>
            <UIObject ControlType="Document" Id="vTigerLoginPage" FriendlyName="vTigerLoginPage" SpecialControlType="None">
              <TechnologyName>Web</TechnologyName>
              <WindowTitles>
                <WindowTitle>vtiger CRM 5 - Commercial Open Source CRM</WindowTitle>
              </WindowTitles>
              <AndCondition Id="SearchCondition">
                <AndCondition Id="Primary">
                  <PropertyCondition Name="ControlType">Document</PropertyCondition>
                  <PropertyCondition Name="Id" />
                  <PropertyCondition Name="TagName">BODY</PropertyCondition>
                  <PropertyCondition Name="RedirectingPage">False</PropertyCondition>
                  <PropertyCondition Name="FrameDocument">False</PropertyCondition>
                </AndCondition>
                <FilterCondition Id="Secondary">
                  <PropertyCondition Name="Title">vtiger CRM 5 - Commercial Open Source CRM</PropertyCondition>
                  <PropertyCondition Name="AbsolutePath">/index.php</PropertyCondition>
                  <PropertyCondition Name="PageUrl">http://localhost:8888/index.php?action=Login&module=Users</PropertyCondition>
                </FilterCondition>
              </AndCondition>
              <SupportLevel>0</SupportLevel>
              <Descendants>
                <UIObject ControlType="Edit" Id="UserName" FriendlyName="user_name" SpecialControlType="None">
                  <TechnologyName>Web</TechnologyName>
                  <WindowTitles>
                    <WindowTitle>vtiger CRM 5 - Commercial Open Source CRM</WindowTitle>
                  </WindowTitles>
                  <AndCondition Id="SearchCondition">
                    <AndCondition Id="Primary">
                      <PropertyCondition Name="ControlType">Edit</PropertyCondition>
                      <PropertyCondition Name="Id" />
                      <PropertyCondition Name="Name">user_name</PropertyCondition>
                      <PropertyCondition Name="TagName">INPUT</PropertyCondition>
                      <PropertyCondition Name="LabeledBy" />
                      <PropertyCondition Name="Type">SINGLELINE</PropertyCondition>
                    </AndCondition>
                    <FilterCondition Id="Secondary">
                      <PropertyCondition Name="Title" />
                      <PropertyCondition Name="Class" />
                      <PropertyCondition Name="ControlDefinition">name=user_name</PropertyCondition>
                      <PropertyCondition Name="TagInstance">5</PropertyCondition>
                    </FilterCondition>
                  </AndCondition>
                  <SupportLevel>0</SupportLevel>
                  <Descendants />
                </UIObject>
                <UIObject ControlType="Edit" Id="Password" FriendlyName="user_password" SpecialControlType="None">
                  <TechnologyName>Web</TechnologyName>
                  <WindowTitles>
                    <WindowTitle>vtiger CRM 5 - Commercial Open Source CRM</WindowTitle>
                  </WindowTitles>
                  <AndCondition Id="SearchCondition">
                    <AndCondition Id="Primary">
                      <PropertyCondition Name="ControlType">Edit</PropertyCondition>
                      <PropertyCondition Name="Id" />
                      <PropertyCondition Name="Name">user_password</PropertyCondition>
                      <PropertyCondition Name="TagName">INPUT</PropertyCondition>
                      <PropertyCondition Name="LabeledBy" />
                      <PropertyCondition Name="Type">PASSWORD</PropertyCondition>
                    </AndCondition>
                    <FilterCondition Id="Secondary">
                      <PropertyCondition Name="Title" />
                      <PropertyCondition Name="Class" />
                      <PropertyCondition Name="ControlDefinition">value="" type=password name=user_passwor</PropertyCondition>
                      <PropertyCondition Name="TagInstance">6</PropertyCondition>
                    </FilterCondition>
                  </AndCondition>
                  <SupportLevel>0</SupportLevel>
                  <Descendants />
                </UIObject>
                <UIObject ControlType="Button" Id="LoginButton" FriendlyName="Login" SpecialControlType="None">
                  <TechnologyName>Web</TechnologyName>
                  <WindowTitles>
                    <WindowTitle>vtiger CRM 5 - Commercial Open Source CRM</WindowTitle>
                  </WindowTitles>
                  <AndCondition Id="SearchCondition">
                    <AndCondition Id="Primary">
                      <PropertyCondition Name="ControlType">Button</PropertyCondition>
                      <PropertyCondition Name="Id">submitButton</PropertyCondition>
                      <PropertyCondition Name="Name" />
                      <PropertyCondition Name="TagName">INPUT</PropertyCondition>
                      <PropertyCondition Name="DisplayText">Login</PropertyCondition>
                    </AndCondition>
                    <FilterCondition Id="Secondary">
                      <PropertyCondition Name="Type">submit</PropertyCondition>
                      <PropertyCondition Name="Title" />
                      <PropertyCondition Name="Class" />
                      <PropertyCondition Name="ControlDefinition">id=submitButton value=Login type=submit</PropertyCondition>
                      <PropertyCondition Name="TagInstance">7</PropertyCondition>
                    </FilterCondition>
                  </AndCondition>
                  <SupportLevel>0</SupportLevel>
                  <Descendants />
                </UIObject>
              </Descendants>
            </UIObject>
            <UIObject ControlType="Document" Id="vTigerAdministartionPage" FriendlyName="vTiger_Administrator - Leads " SpecialControlType="None">
              <TechnologyName>Web</TechnologyName>
              <WindowTitles>
                <WindowTitle>Administrator - Leads - vtiger CRM 5 - Commercial Open Source CRM - Windows Internet Explorer provided by Dell Client Engineeri</WindowTitle>
              </WindowTitles>
              <AndCondition Id="SearchCondition">
                <AndCondition Id="Primary">
                  <PropertyCondition Name="ControlType">Document</PropertyCondition>
                  <PropertyCondition Name="Id" />
                  <PropertyCondition Name="TagName">BODY</PropertyCondition>
                  <PropertyCondition Name="RedirectingPage">False</PropertyCondition>
                  <PropertyCondition Name="FrameDocument">False</PropertyCondition>
                </AndCondition>
                <FilterCondition Id="Secondary">
                  <PropertyCondition Name="Title">Administrator - Leads - vtiger CRM 5 - Commercial Open Source CRM</PropertyCondition>
                  <PropertyCondition Name="AbsolutePath">/index.php</PropertyCondition>
                  <PropertyCondition Name="PageUrl">http://localhost:8888/index.php?module=Leads&action=EditView&return_action=DetailView&parenttab=Marketing</PropertyCondition>
                </FilterCondition>
              </AndCondition>
              <SupportLevel>0</SupportLevel>
              <Descendants>
                <UIObject ControlType="Edit" Id="UILastnameEdit" FriendlyName="lastname" SpecialControlType="None">
                  <TechnologyName>Web</TechnologyName>
                  <WindowTitles>
                    <WindowTitle>Administrator - Leads - vtiger CRM 5 - Commercial Open Source CRM - Windows Internet Explorer provided by Dell Client Engineeri</WindowTitle>
                  </WindowTitles>
                  <AndCondition Id="SearchCondition">
                    <AndCondition Id="Primary">
                      <PropertyCondition Name="ControlType">Edit</PropertyCondition>
                      <PropertyCondition Name="Id" />
                      <PropertyCondition Name="Name">lastname</PropertyCondition>
                      <PropertyCondition Name="TagName">INPUT</PropertyCondition>
                      <PropertyCondition Name="LabeledBy" />
                      <PropertyCondition Name="Type">SINGLELINE</PropertyCondition>
                    </AndCondition>
                    <FilterCondition Id="Secondary">
                      <PropertyCondition Name="Title" />
                      <PropertyCondition Name="Class">detailedViewTextBox</PropertyCondition>
                      <PropertyCondition Name="ControlDefinition">onblur="this.className='detailedViewText</PropertyCondition>
                      <PropertyCondition Name="TagInstance">24</PropertyCondition>
                    </FilterCondition>
                  </AndCondition>
                  <SupportLevel>0</SupportLevel>
                  <Descendants />
                </UIObject>
              </Descendants>
            </UIObject>
          </Descendants>
        </TopLevelWindow>
      </TopLevelWindows>
    </UIMap>
  </Maps>
  <ValueMap>
    <ParameterList />
  </ValueMap>
</UITest>





I specifcally need the values from



I specifcally need the values from

<UIObject ControlType="Document" Id="vTigerLoginPage" FriendlyName="vTigerLoginPage" SpecialControlType="None">





and



and

<UIObject ControlType="Document" Id="vTigerAdministartionPage" FriendlyName="vTiger_Administrator - Leads " SpecialControlType="None">



Only the Id values from these two statements how do i get through C# code


Only the Id values from these two statements how do i get through C# code

推荐答案

XmlDocument doc = new XmlDocument();
//load your doc
XmlNamespaceManager xnm = new XmlNamespaceManager(doc.NameTable);
xnm.AddNamespace("m", "http://schemas.microsoft.com/VisualStudio/TeamTest/UITest/2010");
XmlElement el = (XmlElement) doc.SelectSingleNode("//m:UIObject[@Id='vTigerLoginPage']", xnm);



Although XmlDocument is the most popular option, I don’t recommend to use it if you only need to read from a document. The better option would be to use XPathDocument or XDocument (in later versions of .NET).


Although XmlDocument is the most popular option, I don't recommend to use it if you only need to read from a document. The better option would be to use XPathDocument or XDocument (in later versions of .NET).


这篇关于需要检索特定的XML节点值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 14:24