J'essaie d'analyser une feuille de calcul OpenOffice pour obtenir des lignes avec des valeurs uniques dans la première colonne. I.E., je voudrais récupérer à partir du fragment XML suivant tous les éléments <table:table-row>
avec des valeurs uniques <text:p>
dans le premier enfant <table:table-cell>
.Sélection d'éléments avec des valeurs uniques
<table:table table:name="foo">
<table:table-row>
<table:table-cell>
<text:p>1</text:p>
</table:table-cell>
<table:table-cell>
<text:p>foo</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell>
<text:p>2</text:p>
</table:table-cell>
<table:table-cell>
<text:p>bar</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell>
<text:p>1</text:p>
</table:table-cell>
<table:table-cell>
<text:p>baz</text:p>
</table:table-cell>
</table:table-row>
</table:table>
Je voudrais obtenir la sortie ci-dessous sous forme de nœuds
<table:table-row>
<table:table-cell>
<text:p>1</text:p>
</table:table-cell>
<table:table-cell>
<text:p>foo</text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
<table:table-cell>
<text:p>2</text:p>
</table:table-cell>
<table:table-cell>
<text:p>bar</text:p>
</table:table-cell>
</table:table-row>
Comment puis-je faire avec XPath?
XPath est juste une expression pour obtenir un Elemente défini | Attributs | nœud de votre dom. Ce que vous aimeriez, c'est transformer votre fichier XML initial en un autre. Vous faites cela en utilisant XSLT, puis en utilisant l'expression XPath en utilisant XSLT. – Spredzy
Je voulais obtenir des nœuds, je ne me suis pas dit que je pouvais aussi avoir XML. Merci. – Aru