1 Reply Latest reply on Jun 16, 2006 11:06 AM by Newsgroup_User

    Query to XML

    cutie369 Level 1
      How can I use this script to write an XML file from it?

      <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
      <CFQUERY NAME="qGetNav" DATASOURCE="#application.ds#">
      SELECT T1ID, T1Name, Button_up, Button_dn, Alt_Text, header, ShortName,
      Content
      FROM Tier1
      WHERE Live = true
      ORDER BY ButtonLoc
      </CFQUERY>

      <CFQUERY NAME="qGetTier2" DATASOURCE="#application.ds#">
      SELECT T2ID, T1IDFK, T2Name, Button_up, Button_dn, Alt_Text, header,
      Content, allowcontent
      FROM Tier2
      WHERE Live = true
      ORDER BY ButtonLoc
      </CFQUERY>


      <links>
      <CFOUTPUT QUERY="qGetNav">

      <cfif #url.ID# eq #T1ID#>
      <link name="#T1Name#" ref="level1.cfm?ID=#T1ID#" active="1">
      <cfelse>
      <link name="#T1Name#" ref="level1.cfm?ID=#T1ID#">
      </cfif>
      <cfset parentID = #T1ID# >
      <cfloop query="qGetTier2">
      <cfif parentID eq #T1IDFK#><inLink name="#T2Name#" ref="level2.cfm?ID=#parentID#&T2ID=#T2ID#"/></cfif>
      </cfloop>
      </link>
      </CFOUTPUT>
      </links>
        • 1. Re: Query to XML
          Level 7
          cutie369 wrote:
          > How can I use this script to write an XML file from it?
          >
          > <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
          > <CFQUERY NAME="qGetNav" DATASOURCE="#application.ds#">
          > SELECT T1ID, T1Name, Button_up, Button_dn, Alt_Text, header, ShortName,
          > Content
          > FROM Tier1
          > WHERE Live = true
          > ORDER BY ButtonLoc
          > </CFQUERY>
          >
          > <CFQUERY NAME="qGetTier2" DATASOURCE="#application.ds#">
          > SELECT T2ID, T1IDFK, T2Name, Button_up, Button_dn, Alt_Text, header,
          > Content, allowcontent
          > FROM Tier2
          > WHERE Live = true
          > ORDER BY ButtonLoc
          > </CFQUERY>
          >
          >
          <cfxml variable="myXMLObj">
          > <links>
          > <CFOUTPUT QUERY="qGetNav">
          >
          > <cfif #url.ID# eq #T1ID#>
          > <link name="#T1Name#" ref="level1.cfm?ID=#T1ID#" active="1">
          > <cfelse>
          > <link name="#T1Name#" ref="level1.cfm?ID=#T1ID#">
          > </cfif>
          > <cfset parentID = #T1ID# >
          > <cfloop query="qGetTier2">
          > <cfif parentID eq #T1IDFK#><inLink name="#T2Name#"
          > ref="level2.cfm?ID=#parentID#&T2ID=#T2ID#"/></cfif>
          > </cfloop>
          > </link>
          > </CFOUTPUT>
          > </links>
          </cfxml>

          <cfdump var="myXmlObj">

          <cffile action="write" .... output="#ToString(myXmlObj)#">