2
private const string TECHACCOUNTAMTITEM_AMT_XPATH = @"//Part[translate(@Type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'instalment']/acord:Jv-Ins-Reinsurance/acord:TechAccount/acord:Subaccount/acord:TechAccountAmtItem[translate(@Type, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') != 'ipt' and translate(@AmtStatus, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') != 'informational']/acord:Amt";

var xmlNamespaceManager = this._namespaceManager.GetNamespaceManager(this.TransactionPayload.OuterXml);
                var techAccountAmtItemAmt = Decimal.Parse(this.TransactionPayload.SelectSingleNode(TECHACCOUNTAMTITEM_AMT_XPATH, xmlNamespaceManager).InnerText);

The above two statement gives out the value 4500.

But i dont want to use translate and just want to use it directly to fetech the value .

It seems that != is not working in the below and not fetching the value and resulting in null .

Here is the new Xpath i m trying to achieve but not working .

private const string TECHACCOUNTAMTITEM_AMT_XPATH = @"//Part[@Type = 'Instalment']/acord:Jv-Ins-Reinsurance/acord:TechAccount/acord:Subaccount/acord:TechAccountAmtItem[@Type != 'ipt' and @AmtStatus != 'informational']/acord:Amt";

How can I acheive the same ?

0

1 Answer 1

2

The reason for this is that != requires the attribute to exist, while translate will also produce a result if the attribute is missing.

You need to use not() instead:

.../acord:‌​TechAccountAmtItem[not(@‌​Type = 'ipt') and not(@AmtStatus = 'informational')]/...

This assumes that Type could be missing as well. If not, you can use @Type != 'ipt' instead.

Sign up to request clarification or add additional context in comments.

1 Comment

I have tried [not() and not()] and so many keywords from MSDN but didn't work for hours. I gave it a try this time and it worked like charm. Thanks :) [not(@Type = 'insurance_premium_tax') and not(@AmtStatus = 'informational')]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.