You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Celinio Fernandes <ce...@wanadoo.fr> on 2005/08/09 02:10:25 UTC
Xmlcursors : how to loop and then retrieve the values ?
Hi,
I am new to Xmlcursors and trying to use it to my project.
I have the following XML file:
<TTT>
<AAA> <-- first child TTT
<BBBB>
<CCC> value1</CCC>
<CCC> value2</CCC>
<CCC> value3</CCC>
<CCC> value4</CCC>
</BBBB>
<BBBB>
<CCC> value5</CCC>
<CCC> value6</CCC>
<CCC> value7</CCC>
<CCC> value8</CCC>
</BBBB>
<BBBB>
<CCC> value9</CCC>
<CCC> value10</CCC>
<CCC> value11</CCC>
<CCC> value12</CCC>
</BBBB>
</AAA>
<AAA> <-- second child of TTT
<BBBB>
<CCC> value13</CCC>
<CCC> value14</CCC>
<CCC> value15</CCC>
<CCC> value16</CCC>
</BBBB>
<BBBB>
<CCC> value17</CCC>
<CCC> value18</CCC>
<CCC> value19</CCC>
<CCC> value20</CCC>
</BBBB>
<BBBB>
<CCC> value21</CCC>
<CCC> value22</CCC>
<CCC> value23</CCC>
<CCC> value24</CCC>
</BBBB>
</AAA>
etc ..
</TTT>
So I have a long series of <AAA> sections , with nested tags <BBBB> and
<CCC>
What I want:
To retrieve, for each section of <AAA> elements, a particular value of
<CCC>, against certain criterias (that I would pass through an Xquery
string).
My result would look like this:
For the first set: value9 for instance, for the second set: value16, etc ...
I know how to position the cursor to the first child, <AAA>:
XmlCursor orderCursor = mydoc.newCursor();
orderCursor.toFirstChild();
But then, from there, how do you point to the other first child of
<TTT>: <AAA>?
In other words, how do you loop through all the direct children of
<TTT> ?
I would like to use the power of XQuery combined with XMLCursors to do this.
Could anyone provide me with a little explanation on how to do this and / or
a little example ?
Thanks a lot.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org