Kumar802
(Kumar802)
March 30, 2023, 9:41am
1
Hello all!
I have the following expression, to check if an invoice is present within one of the tags in the response:
xdoc.Root.Descendants(xnamespace+“INVOICE”).Any(Function (x)x.Value.ToUpper.Trim.Equals(InvoiceExtracted))
now, very simply, I capitalize (toupper) the value of my variable, the problem is if the content of the response is not capitalized, how do I change the expression so that the content of the INVOICE tag is also capitalized and avoid mismatch?
Thanks in advance
Yoichi
(Yoichi)
March 30, 2023, 9:54am
2
Hi,
It might not be very good solution, however how about to convert it to uppercase before de-serializing, as the following?
strXML = System.Text.RegularExpressions.Regex.Replace(strXml,"(?i)(?<=</?)invoice","INVOICE")
This assumes there is no element which starts with invoice except “invoice”
Edit: the following expression may be better
System.Text.RegularExpressions.Regex.Replace(strXml,"(?i)(?<=</?)invoice(?=\s|>)","INVOICE")
Regards,
1 Like
Kumar802
(Kumar802)
March 30, 2023, 12:50pm
3
so there is no way to convert the value present in the tag after deserializing it?
The only possibility is to do a replace via regex?
Yoichi
(Yoichi)
March 30, 2023, 2:23pm
4
Hi,
after deserializing it?
Can you try the following expression?
xDoc.Root.Descendants().Where(Function(x) x.Name.LocalName.ToUpper="INVOICE").Any(Function (x)x.Value.ToUpper.Trim.Equals(InvoiceExtracted))
Regards,