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 query:
./root/rows/row/column[@name='Nome'] | ./root/rows/row/column[@name='CPF']
XPath return:
<root>
<column name="Nome">Evandro</column>
<column name="CPF">98765432100</column>
<column name="Nome">Everton</column>
<column name="CPF">12345678900</column>
</root>
What I wish the XPath return:
<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>
I want to make the xpath preserve the document structure when I make the query.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…