469,336 Members | 5,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Export Results in XML Format

Hello everyone,

I am trying to display the results of a query in XML format and cant
seem to get it to work. Has anyone had any trouble exporting PHP/MySQL
-> XML? I am using the following format:
File: xmlexport.php

<?php header("Content-Type: text/xml"); ?>
<?xml version"1.0"?>
<rss version="2.0">
<channel>

<?php
// Database Functions Here to Access Data
echo "<item>$iteminfofromdb</item>";
?>

</channel>
</rss>
This is the basic format i am following. When I just put some plain
XML data in the file and try to access it through my web browser
nothing shows up either. Is there something about using the .php
extension as an XML file?

Thanks,
-Rick

Jul 17 '05 #1
8 10934
"HappyHourHotSpots.com" <Ri*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hello everyone,

I am trying to display the results of a query in XML format and cant
seem to get it to work. Has anyone had any trouble exporting PHP/MySQL
-> XML? I am using the following format:
File: xmlexport.php

<?php header("Content-Type: text/xml"); ?>
<?xml version"1.0"?>
<rss version="2.0">
<channel>

<?php
// Database Functions Here to Access Data
echo "<item>$iteminfofromdb</item>";
?>

</channel>
</rss>
This is the basic format i am following. When I just put some plain
XML data in the file and try to access it through my web browser
nothing shows up either. Is there something about using the .php
extension as an XML file?

Thanks,
-Rick


Linkage?
Jul 17 '05 #2
HappyHourHotSpots.com <Ri*********@gmail.com> wrote:
File: xmlexport.php

<?php header("Content-Type: text/xml"); ?>
<?xml version"1.0"?>
<rss version="2.0"> [snip] </rss>
This is the basic format i am following. When I just put some plain
XML data in the file and try to access it through my web browser
nothing shows up either.


Define nothing shows up! You did look at the source and not at the
rendered version?
Jul 17 '05 #3
Yeah, the source shows only <html><body></body></html>.

Jul 17 '05 #4
HappyHourHotSpots.com <Ri*********@gmail.com> wrote:
Yeah, the source shows only <html><body></body></html>.


Which aren't present in the show script, you shouldn't use IE to debug.

For proper debugging (withaout an actual debugger):
-error_reporting to the max (E_ALL for php4)
-use a client that doesn't mess with output (lynx -source, of a moz/fire*
with with a plugin, or even a packetsniffer)

Jul 17 '05 #5
HappyHourHotSpots.com wrote:
Hello everyone,

I am trying to display the results of a query in XML format and cant
seem to get it to work. Has anyone had any trouble exporting
PHP/MySQL
-> XML? I am using the following format:
File: xmlexport.php

<?php header("Content-Type: text/xml"); ?>
<?xml version"1.0"?>
<rss version="2.0">
<channel>

<?php
// Database Functions Here to Access Data
echo "<item>$iteminfofromdb</item>";
?>

</channel>
</rss>
This is the basic format i am following. When I just put some plain
XML data in the file and try to access it through my web browser
nothing shows up either. Is there something about using the .php
extension as an XML file?

Thanks,
-Rick


It could be that your server has short_open_tag set to on and is having
problems with the xml declaration (the parser sees the <? part of <?xml
and attempts to parse the declaration as php).

If this is the problem, you can either set short_open_tag to 'off' (edit
php.ini or use ini_set() ) or echo / print / etc the xml declaration.

Nick

Jul 17 '05 #6
I was thinking that too, but I have short_open_tags set to off. I
remember seeing that when i was setting up my server so i left it off
just for this reason.

Jul 17 '05 #7
That was actually the show source output that i got from Firefox. Is
there some sort of trick to writing XML with PHP? I figured that if
the file extension ended in PHP it wouldnt matter as long as what was
outputted is in proper XML format.

Jul 17 '05 #8
OK, i changed all my echo()'s to print() instead and now that seems to
have worked but now I am getting an error that says "XML Parsing Error:
xml processing instruction not at start of external entity"

Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

205 posts views Thread by Jeremy Siek | last post: by
6 posts views Thread by maricel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.