Problem with xqueryNode and blank spaces


I have a problem with queryXMLNode, I have the following example:

//ITEM[MA_TRAN_TYPE=1 and (MA_CVE_VTA!= ‘00001’)]

the problem is when in file xml there are tags MA_CVE_VTA with blank spaces both sides, for example, if i apply previos xquery in this xml:

<MA_CVE_VTA> 000001 </MA_CVE_VTA>

My query doesn’t work, because this MA_CVE_VTA appears in my final result , it’s not must happens, but when I remove blank spaces the query the query is OK.

Anyone knows some function for remove blank spaces from XML tag?


Whitespace within XML element content is “significant”. This means “00001” and " 00001 " are different values. The “proper” solution here is to get the source system to not put extraneous whitespace in the value.

But I suspect you’ll say “the source system cannot be changed.” It isn’t a matter of removing the spaces from the data (I don’t think you can) as much as allowing them to exist and still match. The brute force way:

//ITEM[MA_TRAN_TYPE=1 and (MA_CVE_VTA!= ‘00001’) and (MA_CVE_VTA!=’ 00001 ')]

There may be a wildcard or regex way to do this but I’m not sure.