0

I am trying to find a correct xpath to this document its based on Microsoft service center but no matter what I do I cant find the right xpath to get the expression entry's. I have tried /View/Data/Criteria/QueryCriteria/Criteria/FreeformCriteria/Freeform/Criteria and that has not worked.

Now this is valid data cause it is from MICROSOFT SERVICE CENTER MANAGER so its not invalid markup. So can anyone help me the right xpath to find the expression entrys under criteria?

<?xml version="1.0" encoding="utf-8" ?>
      <View>
       <Data>
          <Adapters>
            <Adapter AdapterName="dataportal:EnterpriseManagementObjectProjectionAdapter">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.EnterpriseManagementObjectProjectionAdapter</AdapterType>
            </Adapter>
            <Adapter AdapterName="viewframework://Adapters/AdvancedList">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.ViewFramework</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.ViewFramework.AdvancedListSupportAdapter</AdapterType>
            </Adapter>
            <Adapter AdapterName="omsdk://Adapters/Criteria">
              <AdapterAssembly>Microsoft.EnterpriseManagement.UI.SdkDataAccess</AdapterAssembly>
              <AdapterType>Microsoft.EnterpriseManagement.UI.SdkDataAccess.DataAdapters.SdkCriteriaAdapter</AdapterType>
            </Adapter>
          </Adapters>
          <ItemsSource>
            <AdvancedListSupportClass xmlns="clr-namespace:Microsoft.EnterpriseManagement.UI.ViewFramework;assembly=Microsoft.EnterpriseManagement.UI.ViewFramework" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" DataTypeName="" AdapterName="viewframework://Adapters/AdvancedList" FullUpdateAdapter="dataportal:EnterpriseManagementObjectProjectionAdapter" DataSource="mom:ManagementGroup" IsRecurring="True" RecurrenceFrequency="{x:Static s:Int32.MaxValue}" FullUpdateFrequency="1" Streaming="true">
              <AdvancedListSupportClass.Parameters>
                <QueryParameter Parameter="TypeProjectionId" Value="$MPElement[Name='System.WorkItem.Incident.View.ProjectionType']$" />
              </AdvancedListSupportClass.Parameters>
            </AdvancedListSupportClass>
          </ItemsSource>
          <Criteria>
            <QueryCriteria xmlns="http://tempuri.org/Criteria.xsd" Adapter="omsdk://Adapters/Criteria">
               <Criteria>
                <FreeformCriteria>
                  <Freeform>
                    <Criteria xmlns="http://Microsoft.EnterpriseManagement.Core.Criteria/">
                      <Expression>
                        <And>
                          <Expression>
                            <SimpleExpression>
                              <ValueExpressionLeft>
                                <Property>$Context/Property[Type='CoreIncident!System.WorkItem.Incident']/TierQueue$</Property>
                              </ValueExpressionLeft>
                              <Operator>Equal</Operator>
                              <ValueExpressionRight>
                                <Value>$MPElement[Name="IncidentTierQueuesEnum.Tier2"]$</Value>
                              </ValueExpressionRight>
                            </SimpleExpression>
                          </Expression>
                          <Expression>
                            <SimpleExpression>
                              <ValueExpressionLeft>
                                <Property>$Context/Property[Type='CoreIncident!System.WorkItem.Incident']/Status$</Property>
                              </ValueExpressionLeft>
                              <Operator>NotEqual</Operator>
                              <ValueExpressionRight>
                                <Value>$MPElement[Name="CoreIncident!IncidentStatusEnum.Resolved"]$</Value>
                              </ValueExpressionRight>
                            </SimpleExpression>
                          </Expression>
                          <Expression>
                            <SimpleExpression>
                              <ValueExpressionLeft>
                                <Property>$Context/Property[Type='CoreIncident!System.WorkItem.Incident']/Status$</Property>
                              </ValueExpressionLeft>
                              <Operator>NotEqual</Operator>
                              <ValueExpressionRight>
                                <Value>$MPElement[Name="CoreIncident!IncidentStatusEnum.Closed"]$</Value>
                              </ValueExpressionRight>
                            </SimpleExpression>
                          </Expression>
                          <Expression>
                            <UnaryExpression>
                              <ValueExpression>
                                <GenericProperty Path="$Context/Path[Relationship='WorkItem!System.WorkItemAssignedToUser' SeedRole='Source']$">Id</GenericProperty>
                              </ValueExpression>
                              <Operator>IsNull</Operator>
                            </UnaryExpression>
                          </Expression>
                        </And>
                      </Expression>
                    </Criteria>
                  </Freeform>
                </FreeformCriteria>
              </Criteria>
            </QueryCriteria>
          </Criteria>
        </Data>
          <Presentation>
          <Columns>
            <mux:ColumnCollection xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mux="http://schemas.microsoft.com/SystemCenter/Common/UI/Views/GridView" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:datebinding="clr-namespace:Microsoft.EnterpriseManagement.UI.Extensions;assembly=Microsoft.EnterpriseManagement.UI.Extensions">
              <mux:Column Name="id" DisplayMemberBinding="{Binding Path=Id, Mode=OneWay}" Width="150" DisplayName="Header_Id" Property="Id$ReturnValueAsBigInt$" DataType="s:String" />
              <mux:Column Name="title" DisplayMemberBinding="{Binding Path=Title, Mode=OneWay}" Width="200" DisplayName="Header_Title" Property="Title" DataType="s:String" />
              <mux:Column Name="sDisplayName" DisplayMemberBinding="{Binding Path=Status.DisplayName, Mode=OneWay}" Width="100" DisplayName="Header_Status" Property="Status.DisplayName" DataType="s:String" />
              <mux:Column Name="priority" DisplayMemberBinding="{Binding Path=Priority, Mode=OneWay}" Width="100" DisplayName="Header_Priority" Property="Priority" DataType="s:Int32" />
              <mux:Column Name="targetTime" DisplayMemberBinding="{datebinding:DateBinding Path=TargetResolutionTime, Mode=OneWay}" Width="100" DisplayName="Header_Target_Resolution_Time" Property="TargetResolutionTime" DataType="s:DateTime" />
              <mux:Column Name="aDisplayName" DisplayMemberBinding="{Binding Path=AffectedUser.DisplayName, Mode=OneWay}" Width="150" DisplayName="Header_Affected_User" Property="AffectedUser.DisplayName" DataType="s:String" />
              <mux:Column Name="lastModified" DisplayMemberBinding="{Binding Path=$LastModified$, Mode=OneWay}" Width="150" DisplayName="Header_Last_Modified" Property="$LastModified$" DataType="s:DateTime" />
            </mux:ColumnCollection>
          </Columns>
          <ViewStrings>
            <ViewString ID="Header_Id">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Id"]$</ViewString>
            <ViewString ID="Header_Title">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Title"]$</ViewString>
            <ViewString ID="Header_Status">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Status"]$</ViewString>
            <ViewString ID="Header_Priority">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Priority"]$</ViewString>
            <ViewString ID="Header_Target_Resolution_Time">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Target_Resolution_Time"]$</ViewString>
            <ViewString ID="Header_Affected_User">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Affected_User"]$</ViewString>
            <ViewString ID="Header_Last_Modified">$MPElement[Name="System.WorkItem.Incident.Queue.Tier2.Unassigned.View.Header_Last_Modified"]$</ViewString>
          </ViewStrings>
        </Presentation>
      </View>

Code as requested so far that I am using to get to the elements

       public void  GetCriteraParamters(string QueryParmeterString, string xpath)
        {
            List<QueryCritera> listCriteraParameter = new List<QueryCritera>();

            XmlDocument currentDocument = new XmlDocument();
            currentDocument.LoadXml(QueryParmeterString);
            string path = xpath;
            XmlNodeList nodeList = currentDocument.SelectNodes(path);
            XmlElement elm = currentDocument.DocumentElement;
            XmlNodeList listCritera= elm.ChildNodes;
            List<QueryCritera> qp = new List<QueryCritera>();
            string itemSource="";
            for (int i = 0; i < listCritera.Count; i++)
            {
                QueryCritera qpList = new QueryCritera();

                 string myString = listCritera[i].InnerXml.ToString();


                 string  xml2 = XElement.Parse(myString).ToString();

                 XmlDocument currentDocument2 = new XmlDocument();
                 currentDocument2.LoadXml(xml2);
                 XmlNodeList nodeList2 = currentDocument.SelectNodes(xpath);
                 foreach (XmlNode node in nodeList2)
                 {
                     itemSource = node.InnerXml;


                 }

            }


}

Then I am calling it as follows

myView.GetCriteraParamters(critera, "/Criteria/QueryCriteria/Criteria/FreeformCriteria/Freeform/Criteria/Expression/And/Expression");

csharpdude77
  • 3,221
  • 3
  • 32
  • 80
  • @SergeyBerezovskiy Yes I did i said I wanted to get the expression entrys under Criteria. – csharpdude77 Jun 22 '14 at 12:28
  • Some of these elements are namespaced, specific actions have to be performed to match them. Can you post your current code? The right way depends on the library you're using. – Frédéric Hamidi Jun 22 '14 at 12:29
  • @FrédéricHamidi their you go budy that is how I am processing it – csharpdude77 Jun 22 '14 at 12:32
  • Thanks. Since you're using `XmlDocument` I think I found a suitable duplicate. – Frédéric Hamidi Jun 22 '14 at 12:36
  • @FrédéricHamidi Can you post an example as an answer so I can mark you up thanks – csharpdude77 Jun 22 '14 at 12:39
  • @FrédéricHamidi I am unsure how to apply that to my xml can you provide an example please thanks – csharpdude77 Jun 22 '14 at 12:41
  • That would be redundant, the answers in the duplicate should be enough to get you to speed. There is also a knowledge base article available [here](http://support.microsoft.com/kb/318545). Basically, you have to register the namespaces (the values of the `xmlns` attributes) and associate them with prefixes, then use these prefixes in your XPath expression. – Frédéric Hamidi Jun 22 '14 at 12:46

0 Answers0