Reputation: 718
Below is the code, i just want to locate 8989 instead of ABCD in other set of transaction, usually we are expecting to get mix of items but we want to locate to the tree and node which contains only number data.
Tried searching numeric function in xpath but none seems to suite my case, usually there are only conversion functions available. thing i tried :-
"number(.//dtv:IP[dtv:IPCode='LOGICLABEL']/dtv:IPValue)"
Here, Im getting everything as NaN(Not a numeric) even when this is number.
<dtv:IP>
<dtv:IPCode><![CDATA[LOGICLABEL]]></dtv:IPCode>
<dtv:IPType><![CDATA[STRING]]></dtv:IPType>
<dtv:IPValue><![CDATA[8989]]></dtv:IPValue>
</dtv:IP>
VS
<dtv:IP>
<dtv:IPCode><![CDATA[LOGICLABEL]]></dtv:IPCode>
<dtv:IPType><![CDATA[STRING]]></dtv:IPType>
<dtv:IPValue><![CDATA[ABCD]]></dtv:IPValue>
</dtv:IP>
In above code i just want to get numeric value i.e: 8989 but my xpath should not locate on ABCD. Is it possible in Xpath?
Upvotes: 1
Views: 80
Reputation: 718
"number(.//dtv:IP[dtv:IPCode='LOGICLABEL']/dtv:IPValue)"
This is working good it is working when there are number, only thing is i have to replace the NaN which i described above with 0.
As near was able to get it till now using a translate function.
translate('NaN',number(/dtv:IP[dtv:IPCode='LOGICLABEL']/dtv:IPValue),'0')
My initial analysis with my attempt to solve was wrong, i apologizes for it.
Upvotes: 1