How to update DB with new XML Files??
Wednesday, 1 August 2012 · 2 messages
JB
John Best1 Aug 2012 14:10 #
Hi there,
I am have stored one large document in BaseX DB. Now I want to add more to the same DB.
Is there any simple way to do the same?
Say, I had a file country.xml given below
<Countries>
<Country>A</Country>
<Country>B</Country>
<Country>C</Country>
<Country>D</Country>
</Countries>I stored this in BaseX DB.
Now I have another file with same format
<Countries>
<Country>E</Country>
<Country>F</Country>
<Country>G</Country>
<Country>H</Country>
</Countries>I want this file to update the previous DB....
so that the DB will have in all 8 countries.
Is there any simple way to do this...
--
Have a nice day
JBest
CG
Christian Grün1 Aug 2012 15:17 #
H John,
XQuery Update will help you [1]; this is one option:
for $c in doc('country-new.xml')//Country
return insert node $c into doc('country.xml')/ContriesHope this helps,
Christian
[1] http://docs.basex.org/wiki/Update
Quoted text · John Best · 35 lines
On Wed, Aug 1, 2012 at 2:10 PM, John Best <johnbest5673 at gmail.com> wrote: > Hi there, > > I am have stored one large document in BaseX DB. Now I want to add more to > the same DB. > Is there any simple way to do the same? > > Say, I had a file country.xml given below > > <Countries> > <Country>A</Country> > <Country>B</Country> > <Country>C</Country> > <Country>D</Country> > </Countries> > > I stored this in BaseX DB. > > Now I have another file with same format > > <Countries> > <Country>E</Country> > <Country>F</Country> > <Country>G</Country> > <Country>H</Country> > </Countries> > > I want this file to update the previous DB.... > so that the DB will have in all 8 countries. > > Is there any simple way to do this... > > -- > Have a nice day > JBest
Written for BaseX 7.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery