XML:
<root>
<rows>
<row hash="156458">
<column name="Id">1</column>
<column name="Nome">Evandro</column>
<column name="CPF">98765432100</column>
</row>
<row hash="52458">
<column name="Id">2</column>
<column name="Nome">Everton</column>
<column name="CPF">12345678900</column>
</row>
</rows>
</root>
XPath 查询:
./root/rows/row/column[@name='Nome'] | ./root/rows/row/column[@name='CPF']
XPath 返回:
<root>
<column name="Nome">Evandro</column>
<column name="CPF">98765432100</column>
<column name="Nome">Everton</column>
<column name="CPF">12345678900</column>
</root>
我希望 XPath 返回:
<root>
<rows>
<row hash="156458">
<column name="Nome">Evandro</column>
<column name="CPF">98765432100</column>
</row>
<row hash="52458">
<column name="Nome">Everton</column>
<column name="CPF">12345678900</column>
</row>
</rows>
</root>
当我进行查询时,我想让 xpath 保留文档结构。