export xml using xquery in php
Thursday, 2 February 2012 · 9 messages · last reply 3 Feb 2012
NL
Nafiz Al Naharul Islam Grameenphone IT Ltd.2 Feb 2012 11:06 #
Dear all,
I need help to export xml file using xquery in php.
Regards,
Nafiz -Al Naharul Islam
________________________________
The information contained in this email and any attachment(s) to this email are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient and have received this email and/or its attachment(s) in error, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this email and/or its attachment(s) is strictly prohibited. Please notify the sender immediately and delete this email and any attachments.
WARNING: Computer viruses can be transmitted via email. Although GPIT has taken reasonable precautions to ensure no viruses are present in this email and/or its attachment(s), GPIT does not guarantee that this email and/or its attachments are secure or error-free. The recipient should check this email and any attachment(s) for the presence of viruses. GPIT shall accept no liability whatsoever for any loss or damage arising from the use of this email and/or its attachment(s).
MS
Michael Seiferle2 Feb 2012 11:13 #
Hi Nafiz,
I guess you could use the built in EXPORT command.
Quoted text · Nafiz Al Naharul Islam Grameenphone IT Ltd. · 1 line
> $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;')
This snippet is untested, but should work.
Another (again untested :-)) approach might be:
file_put_contents(
$filename,
$session->execute('XQUERY doc("myDB")')
);Hope this helps :-)
Kind Regards
Michael
Quoted text · Nafiz Al Naharul Islam Grameenphone IT Ltd. · 16 lines
Am 02.02.2012 um 11:06 schrieb Nafiz Al Naharul Islam Grameenphone IT Ltd.: > Dear all, > > I need help to export xml file using xquery in php. > > Regards, > > Nafiz -Al Naharul Islam > > The information contained in this email and any attachment(s) to this email are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient and have received this email and/or its attachment(s) in error, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this email and/or its attachment(s) is strictly prohibited. Please notify the sender immediately and delete this email and any attachments. > > WARNING: Computer viruses can be transmitted via email. Although GPIT has taken reasonable precautions to ensure no viruses are present in this email and/or its attachment(s), GPIT does not guarantee that this email and/or its attachments are secure or error-free. The recipient should check this email and any attachment(s) for the presence of viruses. GPIT shall accept no liability whatsoever for any loss or damage arising from the use of this email and/or its attachment(s). > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
LW
Leo Wörteler2 Feb 2012 11:35 #
Hi Nafiz,
Quoted text · Michael Seiferle · 4 lines
Am 02.02.2012 11:13, schrieb Michael Seiferle: > I guess you could use the built in EXPORT command. > >> $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;')
[...]
Quoted text · Michael Seiferle · 6 lines
> Another (again untested :-)) approach might be: > > file_put_contents( > $filename, > $session->execute('XQUERY doc("myDB")') > );
one should remark that the first approach would store the XML file on the machine the *BaseX instance* is running on, the second one uses the machine where the *web server* is running. So if these are different in your setup, only one of the snippets will work as expected.
Hope that helps,
cheers, Leo
NL
Nafiz Al Naharul Islam Grameenphone IT Ltd.2 Feb 2012 16:05 #
Dear Leo and Michael,
$session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;')Command is not clear to me and where I'll place my xquery ?
But the second one is perfect and its working with xquery.
Thanks for the reply.
Best Regards
Nafiz
Quoted text · Leo Wörteler · 25 lines
-----Original Message----- From: Leo Wörteler [mailto:lw at basex.org] Sent: Thursday, February 02, 2012 4:36 PM Cc: Nafiz Al Naharul Islam Grameenphone IT Ltd.; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] export xml using xquery in php Hi Nafiz, Am 02.02.2012 11:13, schrieb Michael Seiferle: > I guess you could use the built in EXPORT command. > >> $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;') [...] > Another (again untested :-)) approach might be: > > file_put_contents( > $filename, > $session->execute('XQUERY doc("myDB")') > ); one should remark that the first approach would store the XML file on the machine the *BaseX instance* is running on, the second one uses the machine where the *web server* is running. So if these are different in your setup, only one of the snippets will work as expected. Hope that helps, cheers, Leo The information contained in this email and any attachment(s) to this email are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient and have received this email and/or its attachment(s) in error, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this email and/or its attachment(s) is strictly prohibited. Please notify the sender immediately and delete this email and any attachments. WARNING: Computer viruses can be transmitted via email. Although GPIT has taken reasonable precautions to ensure no viruses are present in this email and/or its attachment(s), GPIT does not guarantee that this email and/or its attachments are secure or error-free. The recipient should check this email and any attachment(s) for the presence of viruses. GPIT shall accept no liability whatsoever for any loss or damage arising from the use of this email and/or its attachment(s).
MS
Michael Seiferle2 Feb 2012 17:38 #
Hi Nafiz,
the EXPORT command exports the whole database, hence for the example code below: a file path/to/export.xml would be created on the machine running BaseX, with the serialized results of your database.
Hope this helped clear things up :)
Kind Regards
Michael
Quoted text · Nafiz Al Naharul Islam Grameenphone IT Ltd. · 6 lines
Am 02.02.2012 um 16:05 schrieb Nafiz Al Naharul Islam Grameenphone IT Ltd.: > $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;') > > Command is not clear to me and where I'll place my xquery ? > > But the second one is perfect and its working with xquery.
NL
Nafiz Al Naharul Islam Grameenphone IT Ltd.2 Feb 2012 18:20 #
Hi Michael,
I got it in previous but confused about the xquery?? Where and how I can apply xquery using this command? That is actually my question was.
Best Regards
Nafiz
Quoted text · Michael Seiferle · 17 lines
From: Michael Seiferle [mailto:michael.seiferle at uni-konstanz.de] Sent: Thursday, February 02, 2012 10:38 PM To: Nafiz Al Naharul Islam Grameenphone IT Ltd. Cc: 'Leo Wörteler'; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] export xml using xquery in php Hi Nafiz, the EXPORT command exports the whole database, hence for the example code below: a file path/to/export.xml would be created on the machine running BaseX, with the serialized results of your database. Hope this helped clear things up :) Kind Regards Michael Am 02.02.2012 um 16:05 schrieb Nafiz Al Naharul Islam Grameenphone IT Ltd.: $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;') Command is not clear to me and where I'll place my xquery ? But the second one is perfect and its working with xquery. The information contained in this email and any attachment(s) to this email are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient and have received this email and/or its attachment(s) in error, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this email and/or its attachment(s) is strictly prohibited. Please notify the sender immediately and delete this email and any attachments. WARNING: Computer viruses can be transmitted via email. Although GPIT has taken reasonable precautions to ensure no viruses are present in this email and/or its attachment(s), GPIT does not guarantee that this email and/or its attachments are secure or error-free. The recipient should check this email and any attachment(s) for the presence of viruses. GPIT shall accept no liability whatsoever for any loss or damage arising from the use of this email and/or its attachment(s).
CG
Christian Grün2 Feb 2012 19:25 #
Dear Nafiz,
I would recommend you to first have a closer look at our Client Wiki page, which demonstrates how to work with the client code:
http://docs.basex.org/wiki/Clients
Hope this helps,
Christian
Quoted text · Nafiz Al Naharul Islam Grameenphone IT Ltd. · 81 lines
On Thu, Feb 2, 2012 at 6:20 PM, Nafiz Al Naharul Islam Grameenphone IT Ltd. <nnislam at grameenphone.com> wrote: > Hi Michael, > > > > I got it in previous but confused about the xquery?? Where and how I can > apply xquery using this command? That is actually my question was. > > > > Best Regards > > Nafiz > > > > From: Michael Seiferle [mailto:michael.seiferle at uni-konstanz.de] > Sent: Thursday, February 02, 2012 10:38 PM > To: Nafiz Al Naharul Islam Grameenphone IT Ltd. > Cc: 'Leo Wörteler'; basex-talk at mailman.uni-konstanz.de > > > Subject: Re: [basex-talk] export xml using xquery in php > > > > Hi Nafiz, > > > > the EXPORT command exports the whole database, hence for the example code > below: > > a file path/to/export.xml would be created on the machine running BaseX, > with the serialized results of your database. > > > > Hope this helped clear things up :) > > Kind Regards > > Michael > > Am 02.02.2012 um 16:05 schrieb Nafiz Al Naharul Islam Grameenphone IT Ltd.: > > > > $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;') > > Command is not clear to me and where I'll place my xquery ? > > But the second one is perfect and its working with xquery. > > > > > ________________________________ > The information contained in this email and any attachment(s) to this email > are intended for the exclusive use of the addressee(s) and may contain > proprietary, confidential or privileged information. If you are not the > intended recipient and have received this email and/or its attachment(s) in > error, you are notified that disclosing, copying, distributing or taking any > action in reliance on the contents of this email and/or its attachment(s) is > strictly prohibited. Please notify the sender immediately and delete this > email and any attachments. > > WARNING: Computer viruses can be transmitted via email. Although GPIT has > taken reasonable precautions to ensure no viruses are present in this email > and/or its attachment(s), GPIT does not guarantee that this email and/or its > attachments are secure or error-free. The recipient should check this email > and any attachment(s) for the presence of viruses. GPIT shall accept no > liability whatsoever for any loss or damage arising from the use of this > email and/or its attachment(s). > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
NL
Nafiz Al Naharul Islam Grameenphone IT Ltd.3 Feb 2012 20:31 #
Hi,
May i export a xml according to my required format ....
Currently using xquery i got following....
<tender ID="01">AA</tender>
<tender ID="02">BB</tender>But i want in following format...
<?xml version="1.0" encoding="ISO-8859-1"?>
<tenders>
<tender ID="01">AA</tender>
<tender ID="02">BB</tender>
</tenders>Is it possible in php and Basex?
Regards
Nafiz
Quoted text · Christian Grün · 94 lines
From: Christian Grün [christian.gruen at gmail.com] Sent: Friday, February 03, 2012 12:25 AM To: Nafiz Al Naharul Islam Grameenphone IT Ltd. Cc: Michael Seiferle; Leo Wörteler; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] export xml using xquery in php Dear Nafiz, I would recommend you to first have a closer look at our Client Wiki page, which demonstrates how to work with the client code: http://docs.basex.org/wiki/Clients Hope this helps, Christian On Thu, Feb 2, 2012 at 6:20 PM, Nafiz Al Naharul Islam Grameenphone IT Ltd. <nnislam at grameenphone.com> wrote: > Hi Michael, > > > > I got it in previous but confused about the xquery?? Where and how I can > apply xquery using this command? That is actually my question was. > > > > Best Regards > > Nafiz > > > > From: Michael Seiferle [mailto:michael.seiferle at uni-konstanz.de] > Sent: Thursday, February 02, 2012 10:38 PM > To: Nafiz Al Naharul Islam Grameenphone IT Ltd. > Cc: 'Leo Wörteler'; basex-talk at mailman.uni-konstanz.de > > > Subject: Re: [basex-talk] export xml using xquery in php > > > > Hi Nafiz, > > > > the EXPORT command exports the whole database, hence for the example code > below: > > a file path/to/export.xml would be created on the machine running BaseX, > with the serialized results of your database. > > > > Hope this helped clear things up :) > > Kind Regards > > Michael > > Am 02.02.2012 um 16:05 schrieb Nafiz Al Naharul Islam Grameenphone IT Ltd.: > > > > $session->execute('OPEN myDB; EXPORT path/to/export.xml;CLOSE myDB;') > > Command is not clear to me and where I'll place my xquery ? > > But the second one is perfect and its working with xquery. > > > > > ________________________________ > The information contained in this email and any attachment(s) to this email > are intended for the exclusive use of the addressee(s) and may contain > proprietary, confidential or privileged information. If you are not the > intended recipient and have received this email and/or its attachment(s) in > error, you are notified that disclosing, copying, distributing or taking any > action in reliance on the contents of this email and/or its attachment(s) is > strictly prohibited. Please notify the sender immediately and delete this > email and any attachments. > > WARNING: Computer viruses can be transmitted via email. Although GPIT has > taken reasonable precautions to ensure no viruses are present in this email > and/or its attachment(s), GPIT does not guarantee that this email and/or its > attachments are secure or error-free. The recipient should check this email > and any attachment(s) for the presence of viruses. GPIT shall accept no > liability whatsoever for any loss or damage arising from the use of this > email and/or its attachment(s). > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > The information contained in this email and any attachment(s) to this email are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient and have received this email and/or its attachment(s) in error, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this email and/or its attachment(s) is strictly prohibited. Please notify the sender immediately and delete this email and any attachments. WARNING: Computer viruses can be transmitted via email. Although GPIT has taken reasonable precautions to ensure no viruses are present in this email and/or its attachment(s), GPIT does not guarantee that this email and/or its attachments are secure or error-free. The recipient should check this email and any attachment(s) for the presence of viruses. GPIT shall accept no liability whatsoever for any loss or damage arising from the use of this email and/or its attachment(s).
CG
Christian Grün3 Feb 2012 20:41 #
Sure that's possible. Basically, nearly everything is possible with XQuery; sometimes, it's just a challenge to guess how to do it best. The BaseX query editor might help you here. Just play around with the following query in the BaseX GUI, and call it from PHP as soon as it does what you need:
declare option output:omit-xml-declaration "no";
declare option output:encoding "ISO-8859-1";
let $results := (
<tender ID="01">AA</tender>,
<tender ID="02">BB</tender>
) return
<tenders>{ $results }</tenders>Christian
_______________________________________
On Fri, Feb 3, 2012 at 8:31 PM, Nafiz Al Naharul Islam Grameenphone IT Ltd.
Quoted text · Nafiz Al Naharul Islam Grameenphone IT Ltd. · 19 lines
> May i export a xml according to my required format .... > > Currently using xquery i got following.... > > <tender ID="01">AA</tender> > <tender ID="02">BB</tender> > > But i want in following format... > > <?xml version="1.0" encoding="ISO-8859-1"?> > <tenders> > <tender ID="01">AA</tender> > <tender ID="02">BB</tender> > </tenders> > > Is it possible in php and Basex? > > Regards > Nafiz
Written for BaseX 7.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery