Export Results in XML Format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HappyHourHotSpots.com

    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>$iteminf ofromdb</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

  • Joshua Beall

    #2
    Re: Export Results in XML Format

    "HappyHourHotSp ots.com" <Rick.Pinney@gm ail.com> wrote in message
    news:1111077756 .541398.155120@ f14g2000cwb.goo glegroups.com.. .[color=blue]
    > 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>$iteminf ofromdb</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
    >[/color]

    Linkage?


    Comment

    • Daniel Tryba

      #3
      Re: Export Results in XML Format

      HappyHourHotSpo ts.com <Rick.Pinney@gm ail.com> wrote:[color=blue]
      > File: xmlexport.php
      >
      > <?php header("Content-Type: text/xml"); ?>
      > <?xml version"1.0"?>
      > <rss version="2.0">[/color]
      [snip][color=blue]
      > </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.[/color]

      Define nothing shows up! You did look at the source and not at the
      rendered version?

      Comment

      • HappyHourHotSpots.com

        #4
        Re: Export Results in XML Format

        Yeah, the source shows only <html><body></body></html>.

        Comment

        • Daniel Tryba

          #5
          Re: Export Results in XML Format

          HappyHourHotSpo ts.com <Rick.Pinney@gm ail.com> wrote:[color=blue]
          > Yeah, the source shows only <html><body></body></html>.[/color]

          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)

          Comment

          • Nick Robins

            #6
            Re: Export Results in XML Format

            HappyHourHotSpo ts.com wrote:
            [color=blue]
            > 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>$iteminf ofromdb</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[/color]

            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

            Comment

            • HappyHourHotSpots.com

              #7
              Re: Export Results in XML Format

              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.

              Comment

              • HappyHourHotSpots.com

                #8
                Re: Export Results in XML Format

                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.

                Comment

                • HappyHourHotSpots.com

                  #9
                  Re: Export Results in XML Format

                  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"

                  Comment

                  Working...