5 Replies Latest reply on Oct 12, 2007 5:51 AM by gmurnock

    XML from CF not well-formed?

    Keith Dodd Level 1
      I have been working through the Training from the Source book on Flex2 (Trapper, Boles, Talbot, etc.). In Lesson 17, it deals with accessing server-side objects.

      One piece of code accesses a CF template, which brings in an XML file:
      <mx:HTTPService id="prodByCatRPC"
      url=" http://localhost/flexGrocer/xml/categorizedProducts.cfm"
      resultFormat="e4x" />
      The CF plate from the book's file has the following:
      <cfheader name="Expires" value="#now()#" />

      <cfxml variable="xProducts">
      <cfinclude template="categorizedProducts.xml">

      <cfset xmlObject=ToString(xProducts)>

      <cfcontent type="text/xml" />
      When run the Flex file, I get a run-time message which seems to indicate that the XML is not well-formed. (Here is a bit of the message; not sure I'm understanding it!):

      [RPC Fault faultString="Error #1088: The markup in the document following the root element must be well-formed." faultCode="Client.CouldNotDecode" faultDetail="null"]

      I am ASSUMING that the CF page is not returning the xml as desired, because if I simply change the flex http service call to the xml file that the CF page is including, the flex app runs as expected and without errors:
      url=" http://localhost/flexGrocer/xml/categorizedProducts.xml"

      (something in the posting mech is making the above url statement messed up, but you can probably tell what I mean)

      I am a CF developer and although haven't used the book's exact method to get the cf generated xml, I have done so successfully for Spry and other things.
      I tried some ot the things I had to do to get the CF generated xml to work in Spry with this flex, but didn't help. Tried adding a reset='true" with the cfcontent tag; tried making the cfcontent wrap the output; added cfprocessing tags to suppresswhitespace.

      Appreciate any thoughts/help on how to solve this. Also, whether others agree that the problem is with the generated xml rather than something else.

        • 1. Re: XML from CF not well-formed?
          Keith Dodd Level 1
          After more experimenting, I found the problem: Hadn't set the CF settings to NOT show debugging output. Making that setting, made it all work fine.

          Oh, the little things that cause big problems!

          • 2. Re: XML from CF not well-formed?
            Hi Keith, Where did you set the CF setting to not show debugging output?
            • 3. Re: XML from CF not well-formed?

              Originally posted by: spatz04
              Hi Keith, Where did you set the CF setting to not show debugging output?

              Its okay - I get it - the admin console. Solved my problem...
              • 4. Re: XML from CF not well-formed?
                Keith Dodd Level 1
                I don't remember the exact context when I first posted this question and answered it; but, if one doesn't want to change overall settings for debugging in cf admin., I *think* you can ajust for a specific area using cfsetting and/or cfprocessingdirective. There's a number of attributes and combinations there that I think can take care of the problem. I forget for sure, but may want to try that, especially on a development box where you might generally want debugging to be on.

                Also, if using cfcs in any part of what you generate, they can produce whitespace. To solve (or minimize), make sure that output attribute in the component is false and that output in function is false (unless directly outputting within the function.

                Seems like CF and whitespace is an ongoing item to try to manage.

                • 5. Re: XML from CF not well-formed?
                  Debugging in CF... I had that problem once too...
                  Another note in CF - any data sent back to FLEX I change everything (most everything) into an array from a QRY before sending it back to FLEX. Then in FLEX I set the results to an ArrayCollection. Faster data exchange as an array than as a qry dataType.