我正在使用一些 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] 但这不起作用。有任何想法吗?