我正在使用一些XML,而不是真正的技术倾向,并试图通过阅读互联网上的各种来源来解决这个问题,但无法快速实现。
我有以下XML:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<XXXSoapHeader xmlns="http://XXX.com/optima/webservices">
<AuthenticationString>?</AuthenticationString>
</XXXSoapHeader>
</soap:Header>
<soap:Body>
<SubmitMultipleCalcMarginRequestResponse xmlns="http://XXX.com/optima/webservices">
<SubmitMultipleCalcMarginRequestResult>
<TaskExecutionSubmitInfo>
<taskExecutionId>74457</taskExecutionId>
<description>Calc LIVE BROKER margin : Account WebServiceTest_Account1(435) : Business Date (12-Feb-2007)</description>
</TaskExecutionSubmitInfo>
<TaskExecutionSubmitInfo>
<taskExecutionId>74458</taskExecutionId>
<description>Calc LIVE BROKER margin : Account WebServiceTest_Account2(436) : Business Date (12-Feb-2007)</description>
</TaskExecutionSubmitInfo>
</SubmitMultipleCalcMarginRequestResult>
</SubmitMultipleCalcMarginRequestResponse>
</soap:Body>
</soap:Envelope>
并且一直使用以下方法从节点中提取信息:
//*[name() = 'taskExecutionId']
返回:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://XXX.com/optima/webservices">
<taskExecutionId>74457</taskExecutionId>
<taskExecutionId>74458</taskExecutionId>
</root>
但是,如果我想仅返回第二个taskExecutionId,我该怎么办?还是第一个?我尝试用[n]附加,但这不起作用。有什么想法吗?