2014-05-02 56 views
0

我正在使用XPath从以下xml文档中获取值。如何使用XPath获取多个值?

<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 

我的问题是,要获得多个值我要送我查询了很多次,周而复始。

是否有可能检索三个值,如VotesWinner,VotesFirstRunnerUp,VotesSecondRunnerUp与一个XPath字符串之间插入逗号分隔值?

+0

非常感谢,这对我的作品。 –

+0

由于将其作为答案发布,因此删除了我的评论。 – Dacto

+0

@sumitkang请确保为您的问题使用正确的格式。这包括在极少数情况下使用大标题。否则,它会让我的眼睛受伤... – dirkk

回答

0

您可以使用Union运营商'|'来选择所有三个,然后执行一些后处理。

喜欢的东西:

/const/VotesWinner|/const/VotesFirstRunnerUp|/const/VotesSecondRunnerUp 

再点缀以逗号返回列表。

[转换从评论回答]