1 Reply Latest reply on Jul 25, 2007 9:58 AM by Arbello

    Run query in xml to load sql db info

      Please help. I'm a coldfusion programmer but never mixed flash, coldfusion, xml and sql together until now. I'm trying to run a slide show off of an xml file but I want it to be dynamic. I want to be able to upload a new image, put the image name in the db, and xml will run a query to pull all the image information from the db. I tried this code that I found but got an error:

      <?xml version="1.0" ?>

      SELECT xmlelement(name "images", xmlelement(name "pic", xmlelement(name "image", image)))
      FROM pic

      The error was:
      The XML page cannot be displayed
      Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


      Invalid at the top level of the document. Error processing resource ' http://url_address.com/photos.xml'. Line 1, Position ...

      <?xml version="1.0" ?>

      How can I do this? Ultimately i'll have the site allow the user to upload an image, the system will insert the info into the db and the xml will read from there with the final product being an updated slide show.

      Please help!!!!!!
        • 1. Re: Run query in xml to load sql db info
          Time limited reply:

          You can't put SQL in an XML and expect the browser to know what to do with that (xml is not rendered on the server, like a cfm). A better way to do this would be to run the query in a CFQUERY and build the XML using the results array. A query result does not automagically conform to the XML spec. You may have to do some massaging to make the XML come out how you want.

          I dunno... you're mixing a few technologies without all of the proper steps. I'm not sure why you want to send an XML file down to the browser in the first place.... (especially without a schema, or stylesheet to actually give it a look).

          Perhaps someone with more time can give some better ideas.... Read up on how XML/XHTML works for now. (You may not want to use it)