Hello, I need some help to query a database of thousands of xml files. They are structured only with elements with no attributes :
file1.xml <A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
file2.xml <A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
and so on file3.xml, file4.xml....
Having the value of the <C> element, I would like to have the text of the <E> element.
What is the good query to do this ?
Best regards
Florent
The value of the <C> element is different in each file.
On Tue, Dec 23, 2014 at 6:14 PM, Florent Gallaire fgallaire@gmail.com wrote:
Hello, I need some help to query a database of thousands of xml files. They are structured only with elements with no attributes :
file1.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
file2.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
and so on file3.xml, file4.xml....
Having the value of the <C> element, I would like to have the text of the <E> element.
What is the good query to do this ?
Best regards
Florent
-- FLOSS Engineer & Lawyer
Hello Florent,
the query
/A/B[C = 'value']/D/E/text()
should apply the text index and should be sufficiently fast. Do you encouter any problems with this approach? As a general note you most likely always want to avoid having descendant-or-self steps (i.e. //), as it has to search the whole XML (sub)tree. So being as specific as possible in giving the path is always a good idea.
Merry BaseX-mas, Dirk
On 12/23/2014 06:16 PM, Florent Gallaire wrote:
The value of the <C> element is different in each file.
On Tue, Dec 23, 2014 at 6:14 PM, Florent Gallaire fgallaire@gmail.com wrote:
Hello, I need some help to query a database of thousands of xml files. They are structured only with elements with no attributes :
file1.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
file2.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
and so on file3.xml, file4.xml....
Having the value of the <C> element, I would like to have the text of the <E> element.
What is the good query to do this ?
Best regards
Florent
-- FLOSS Engineer & Lawyer
Hi Florent, thanks Dirk,
/A/B[C = 'value']/D/E/text()
I was about to give a pretty similar answer:
/A[B/C = 'value']/D/E/text()
As B and D are on the same level, you will have to move the B step into the predicate.
Cheers, Christian
should apply the text index and should be sufficiently fast. Do you encouter any problems with this approach? As a general note you most likely always want to avoid having descendant-or-self steps (i.e. //), as it has to search the whole XML (sub)tree. So being as specific as possible in giving the path is always a good idea.
Merry BaseX-mas, Dirk
On 12/23/2014 06:16 PM, Florent Gallaire wrote:
The value of the <C> element is different in each file.
On Tue, Dec 23, 2014 at 6:14 PM, Florent Gallaire fgallaire@gmail.com wrote:
Hello, I need some help to query a database of thousands of xml files. They are structured only with elements with no attributes :
file1.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
file2.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
and so on file3.xml, file4.xml....
Having the value of the <C> element, I would like to have the text of the <E> element.
What is the good query to do this ?
Best regards
Florent
-- FLOSS Engineer & Lawyer
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
Thanks a lot Dirk and Christian. The Chrisitian solution works fine for me.
BaseX is great and you too !
Merry BaseX-mas,
Florent
On Tue, Dec 23, 2014 at 6:26 PM, Christian Grün christian.gruen@gmail.com wrote:
Hi Florent, thanks Dirk,
/A/B[C = 'value']/D/E/text()
I was about to give a pretty similar answer:
/A[B/C = 'value']/D/E/text()
As B and D are on the same level, you will have to move the B step into the predicate.
Cheers, Christian
should apply the text index and should be sufficiently fast. Do you encouter any problems with this approach? As a general note you most likely always want to avoid having descendant-or-self steps (i.e. //), as it has to search the whole XML (sub)tree. So being as specific as possible in giving the path is always a good idea.
Merry BaseX-mas, Dirk
On 12/23/2014 06:16 PM, Florent Gallaire wrote:
The value of the <C> element is different in each file.
On Tue, Dec 23, 2014 at 6:14 PM, Florent Gallaire fgallaire@gmail.com wrote:
Hello, I need some help to query a database of thousands of xml files. They are structured only with elements with no attributes :
file1.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
file2.xml
<A> <B> <C>value</C> </B> <D> <E>text</E> </D> </A>
and so on file3.xml, file4.xml....
Having the value of the <C> element, I would like to have the text of the <E> element.
What is the good query to do this ?
Best regards
Florent
-- FLOSS Engineer & Lawyer
-- Dirk Kirsten, BaseX GmbH, http://basex.org |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
basex-talk@mailman.uni-konstanz.de