Требуется помощь для чтения вложенных / многократных тегов xml с использованием XPath и XPathAll.
Пример:
<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 и дочерних тегов 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