我正在使用XPath从以下xml文档中获取值。
<Const>
<MemberLeader>xyz/MemberLeader>
<FirstRunnerUp>txz</FirstRunnerUp>
<SecondRunnerUp>abc</SecondRunnerUp>
<PartyWinner>AAP</PartyWinner>
<PartyRunnerUp>BJP</PartyRunnerUp>
<PartySecondRunnerUp>Congress</PartySecondRunnerUp>
<VotesWinner>4565</VotesWinner>
<VotesFirstRunnerUp>4362</VotesFirstRunnerUp>
<VotesSecondRunnerUp>6652</VotesSecondRunnerUp>
</Const>
我正在使用此XPath
/const/VotesWinner
我的问题是,要获得多个值,我必须多次发送我的查询。
我是否可以使用一个XPath字符串检索三个值,如VotesWinner,VotesFirstRunnerUp,VotesSecondRunnerUp,并在分隔值之间插入逗号?
答案 0 :(得分:0)
您可以使用 Union 运算符“|
”来选择所有三个,然后执行一些后期处理。
类似的东西:
/const/VotesWinner|/const/VotesFirstRunnerUp|/const/VotesSecondRunnerUp
然后用逗号散布返回的列表。
[从评论转换为答案。]