使用xpath计算逗号数

使用xpath计算逗号数,xpath,Xpath,我试图编写一个xpath表达式来计算元素中逗号的数量。有可能吗?如果是,那么有人能帮我表达一下吗。我需要计算节点中的逗号 <SOISWPUpload> <User>admin</User> <SWPIdentifiers>,,,,,U,,,SWP,20120630,,,,4113,,COAC,TLMCOAC ,,,,,U,,,SWP,20120630,,,,4113,,COAC,TLMCOAC</SWPIdentifiers>

我试图编写一个xpath表达式来计算元素中逗号的数量。有可能吗?如果是,那么有人能帮我表达一下吗。我需要计算节点中的逗号

<SOISWPUpload>
  <User>admin</User>
  <SWPIdentifiers>,,,,,U,,,SWP,20120630,,,,4113,,COAC,TLMCOAC
,,,,,U,,,SWP,20120630,,,,4113,,COAC,TLMCOAC</SWPIdentifiers>
</SOISWPUpload>

管理
水处理厂,20120630,4113,COAC,TLMCOAC
水处理厂,20120630,4113,COAC,TLMCOAC
提前感谢。

使用:

string-length() - string-length(translate(., ',', '')
在这种具体情况下,您可能需要指定上下文节点:

string-length(/*/SWPIdentifiers) - string-length(translate(/*/SWPIdentifiers, ',', '')
使用

string-length() - string-length(translate(., ',', '')
在这种具体情况下,您可能需要指定上下文节点:

string-length(/*/SWPIdentifiers) - string-length(translate(/*/SWPIdentifiers, ',', '')

@用户1567386:我很高兴我的回答对你有用。请你(通过点击旁边的复选标记)接受答案好吗?@user1567386:我很高兴我的答案对你有用。请你(点击旁边的复选标记)接受答案好吗?