需要帮助才能使用xpath和xpathall读取嵌套/多次出现的xml标记示例:
<ProductInfo>
<code>100</code>
<entryInfo>
<statusCode>10</statusCode>
<startTime>11</startTime>
<endTime>12</endTime>
</entryInfo>
<entryInfo>
<statusCode>20</statusCode>
<startTime>21</startTime>
<endTime>22</endTime>
<strengthValue>23</strengthValue>
<strengthUnits>24</strengthUnits>
</entryInfo>
<entryInfo>
<statusCode>30</statusCode>
<endTime>32</endTime>
<strengthValue>33</strengthValue>
<strengthUnits>34</strengthUnits>
<extra>35</extra>
</entryInfo>
</ProductInfo>
预期产量:100,10,11,12,,,,,20,21,22,23,24,30,32,33,34,35
读取entryinfo和child标记的第一个匹配项时,xpath将转到$0的第二个匹配项以查找缺少的标记
XPathAll(x,’ProductInfo/entryInfo/statusCode’).$0,
XPathAll(x,’ProductInfo/entryInfo/startTime’).$0,
XPathAll(x,’ProductInfo/entryInfo/endTime’).$0,
XPathAll(x,’ProductInfo/entryInfo/strengthValue’).$0,
XPathAll(x,’ProductInfo/entryInfo/strengthUnits’).$0,
XPathAll(x,’ProductInfo/entryInfo/extra’).$0
输出;10,11,12,23,24,36
暂无答案!
目前还没有任何答案,快来回答吧!