У меня есть вводимый XML вот так -
<parent>
<child type="reference">
<grandChild name="aaa" action="None">
<Attribute name="xxx">1</Attribute>
<grandChild name="bbb" action="None">
<Attribute name="xxx">1</Attribute>
</grandChild>
<grandChild name="aaa" action="None">
<Attribute name="xxx">2</Attribute>
</grandChild>
</grandChild>
<grandChild name="ddd" action="None">
<Attribute name="xxx">1</Attribute>
<grandChild name="aaa" action="None">
<Attribute name="xxx">3</Attribute>
</grandChild>
</grandChild>
</child>
</parent>
и я хочу вытащить все узлы grandChild, агрегированные по их имени. Например, если я хочу вытащить payload.parent.child.*grandChild filter($.@name == 'aaa')
, я должен получить список массивов с 3 узлами grandChild. Есть ли способ добиться этого?
Спасибо за помощь.
Выход -
<grandChilds>
<grandChild name="aaa" action="None">
<Attribute name="xxx">1</Attribute>
</grandChild>
<grandChild name="aaa" action="None">
<Attribute name="xxx">2</Attribute>
</grandChild>
<grandChild name="aaa" action="None">
<Attribute name="xxx">3</Attribute>
</grandChild>
</grandChilds>