XPath で再帰的 AND 条件付き選択を使用するにはどうすればよいですか?
たとえば、次のドキュメントがあるとします。
<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<file name="foo.mp4">
<chunks>
<file>
<chunks>
<file>
<chunks>
<file>1</file>
<file>2</file>
<file>3</file>
<file>4</file>
</chunks>
</file>
<file>
<chunks>
<file>5</file>
<file>6</file>
<file>7</file>
<file>8</file>
</chunks>
</file>
</chunks>
</file>
<file>
<chunks>
<file>
<chunks>
<file>9</file>
<file>10</file>
<file>11</file>
<file>12</file>
</chunks>
</file>
<file>
<chunks>
<file>13</file>
<file>14</file>
<file>15</file>
<file>16</file>
</chunks>
</file>
</chunks>
</file>
</chunks>
</file>
</root>
私はちょうど選択したい:
<file>1</file>
<file>2</file>
<file>3</file>
<file>4</file>
したがって、効果的にこれ:
//[name="foo.mp4"]/chunks/*[1]/chunks/*[1]/*
しかし、一般化されたアプローチ、つまり、さらに深くネストされたオブジェクトをカバーするものを使用します。このようなもの:
//[name="foo.mp4"]/(chunks/*[1]/)+/*
(cond)+
XPath構文ではなく、私が望むものの正規表現のような表現です。