Selecting Elements by Attribute Values

Below is the example of using the GetDimElements operation to get information about specific elements that satisfy the specified filtering conditions. The request contains moniker of opened dictionary instance and getting parameters, in which the elements filter is specified. The filter uses text of objects' names, it is case-insensitive and searches for text in all parts of names. The basic information is loaded for the selected elements: key, name, element level and indication of child elements. Information is available in the response to the request.

In the C# example the text to be searched for in the names is sent as an input parameter.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetDimElements xmlns="http://www.fsight.ru/PP.SOM.Som">
<tDim xmlns="">
  <id>S1!M!S!S1</id>
  </tDim>
<tArg xmlns="">
<filter>
<text>
  <attributes>NAME</attributes>
  <text>second</text>
  <wholeWordsOnly>false</wholeWordsOnly>
  <caseSensitive>false</caseSensitive>
  </text>
  <includeParents>true</includeParents>
  <includeParentsWithSiblings>true</includeParentsWithSiblings>
  </filter>
<pattern>
  <getLevel>true</getLevel>
  <getImageIndex>true</getImageIndex>
  </pattern>
  </tArg>
  </GetDimElements>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<GetDimElementsResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<els xmlns="">
<e x="1" l="0">
  <n>Item 1</n>
  <k>1</k>
  <h>1</h>
  <o>0</o>
  </e>
<e l="1">
  <n>Item 2</n>
  <k>2</k>
  <h>0</h>
  <o>1</o>
  </e>
<e x="1" l="0">
  <n>Item 4</n>
  <k>4</k>
  <h>0</h>
  <o>0</o>
  </e>
<e x="1" l="0">
  <n>Fifth element</n>
  <k>5</k>
  <h>0</h>
  <o>0</o>
  </e>
  </els>
<id xmlns="">
  <id>S1!M!S!S1</id>
  </id>
  </GetDimElementsResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"GetDimElements" :
{
"tDim" :
{
"id" : "S1!M!S!S1"
},
"tArg" :
{
"filter" :
{
"text" :
{
"attributes" : "NAME",
"text" : "second",
"wholeWordsOnly" : "false",
"caseSensitive" : "false"
},
"includeParents" : "true",
"includeParentsWithSiblings" : "true"
},
"pattern" :
{
"getLevel" : "true",
"getImageIndex" : "true"
}
}
}
}

JSON response:

{
"GetDimElementsResult" :
{
"els" :
{
"e" :
[
{
"@x" : "1",
"@l" : "0",
"n" : "First element",
"k" : "1",
"h" : "1",
"o" : "0"
},
{
"@l" : "1",
"n" : "Second element",
"k" : "2",
"h" : "0",
"o" : "1"
},
{
"@x" : "1",
"@l" : "0",
"n" : "Fourth element",
"k" : "4",
"h" : "0",
"o" : "0"
},
{
"@x" : "1",
"@l" : "0",
"n" : "Fifth element",
"k" : "5",
"h" : "0",
"o" : "0"
}
]
},
"id" :
{
"id" : "S1!M!S!S1"
}
}
}
public static GetDimElementsResult GetFilteredElements(DmId moniker, string text)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tElements = new GetDimElements()
{
tArg = new GetDimElementsArg()
{
pattern = new ElsPattern()
{
getLevel = true
},
//Element filtering parameters
filter = new ElsFilter()
{
text = new TextFilter()
{
attributes = "NAME",
text = text,
caseSensitive = false,
wholeWordsOnly = false
},
includeParents = true,
includeParentsWithSiblings = true
}
},
tDim = moniker
};
//Get information about dictionary elements
var result = somClient.GetDimElements(tElements);
return result;
}

See also:

GetDimElements