Dear Friends
I have some problems to get the distinct values from an XML
--------------------------
--
<Test1>
<MetadataEntity>
<AccountID>1</AccountID>
<OrganizationCode>12</Orga
nizationCo
de>
<ClientName>VRK Trusts</ClientName>
</MetadataEntity>
<MetadataEntity>
<AccountID>1</AccountID>
<OrganizationCode>14</Orga
nizationCo
de>
<ClientName>GK Logistics</ClientName>
</MetadataEntity>
<MetadataEntity>
<AccountID>1</AccountID>
<OrganizationCode>14</Orga
nizationCo
de>
<ClientName>VRK Trusts</ClientName>
</MetadataEntity>
<MetadataEntity>
<AccountID>1</AccountID>
<OrganizationCode>14</Orga
nizationCo
de>
<ClientName>GK Logistics</ClientName>
</MetadataEntity>
</Test1>
------------------
I want to get the distinct Client names for account id 1 and organization code
I used the follwing XPath Query
/Test1/MetadataEntity[Acco
untID = 1 and OrganizationCode = 14 and ( not ( ClientName = preceding-sibling::Metadat
aEntity/Cl
ientName))
]/ClientNa
me
It doesnot successful
I get only "GK Logistics" I did not get "VRK Trusts"
I think VRK Trusts was found on the first node and the query skips it.???
Help Me on this plz....
My Code in .NET C#
--------------------------
XPathDocument xPathDoc = new XPathDocument(@"E:\Test1.x
ml");
XPathNavigator xnav = xPathDoc.CreateNavigator()
;
XPathExpression expression = xnav.Compile("/Test1/Metad
ataEntity[
AccountID = 1 and OrganizationCode = 14 and ( not ( ClientName = preceding-sibling::Metadat
aEntity/Cl
ientName))
]/ClientNa
me");
expression.AddSort(".", XmlSortOrder.Ascending, XmlCaseOrder.None,
"", XmlDataType.Text);
XPathNodeIterator iterator = xnav.Select(expression);
while (iterator.MoveNext())
{
XPathNavigator nav2 = iterator.Current.Clone();
MessageBox.Show(nav2.Value
);//iterat
or1.Curren
t.Value);
}
--------------------------
regards
prakash
Start Free Trial