If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > PHP return data as XML data (db2-execute)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-12, 02:49
tempe tempe is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
PHP return data as XML data (db2-execute)

Hello

I tried to get XML data as described in Example #5 Returning SQL data as part of a larger XML document on page
PHP: db2_execute - Manual

Quote:
<?php

$conn = db2_connect("SAMPLE", "db2inst1", "ibmdb2");

$query = '
SELECT
XMLSERIALIZE(
XMLQUERY(\'
declare boundary-space strip;
declare default element namespace "http://posample.org";
<promoList> {
for $prod in $doc/product
where $prod/description/price < 10.00
order by $prod/description/price ascending
return(
<promoitem> {
$prod,
<startdate> {$start} </startdate>,
<enddate> {$end} </enddate>,
<promoprice> {$promo} </promoprice>
} </promoitem>
)
} </promoList>
\' passing by ref DESCRIPTION AS "doc",
PROMOSTART as "start",
PROMOEND as "end",
PROMOPRICE as "promo"
RETURNING SEQUENCE)
AS CLOB (32000))
AS NEW_PRODUCT_INFO
FROM PRODUCT
WHERE PID = ?
';

$stmt = db2_prepare($conn, $query);

$pid = "100-100-01";

if ($stmt) {
db2_bind_param($stmt, 1, "pid", DB2_PARAM_IN);
db2_execute($stmt);

while($row = db2_fetch_array($stmt)){
printf("$row[0]\n");
}
}

db2_close($conn);

?>
instead as result previewed on the page
Quote:
<promoList xmlns="http://posample.org">
<promoitem>
<product pid="100-100-01">
<description>
<name>Snow Shovel, Basic 22 inch</name>
<details>Basic Snow Shovel, 22 inches wide, straight handle with D-Grip</details>
<price>9.99</price>
<weight>1 kg</weight>
</description>
</product>
<startdate>2004-11-19</startdate>
<enddate>2004-12-19</enddate>
<promoprice>7.25</promoprice>
</promoitem>
</promoList>
I get the result with no XML Tags like this

Quote:
Snow Shovel, Basic 22 inchBasic Snow Shovel, 22 inches wide, straight handle with D-Grip9.991 kg2004-11-192004-12-197.25
Thanks.
Reply With Quote
  #2 (permalink)  
Old 01-10-12, 06:36
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Look at the HTML source produced by this PHP (e.g. using Ctrl-U in your browser).
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #3 (permalink)  
Old 01-10-12, 23:15
tempe tempe is offline
Registered User
 
Join Date: Oct 2010
Posts: 27
html source produced shows the xml tags..

Quote:
<promoList><promoitem><product pid="100-100-01"><description><name>Snow Shovel, Basic 22 inch</name><details>Basic Snow Shovel, 22 inches wide, straight handle with D-Grip</details><price>9.99</price><weight>1 kg</weight></description></product><startdate>2004-11-19</startdate><enddate>2004-12-19</enddate><promoprice>7.25</promoprice></promoitem></promoList>
but.. not in the browser
Reply With Quote
  #4 (permalink)  
Old 01-11-12, 02:49
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
You'll have to learn some HTML, then!
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On