Skip to main content
Inspiring
January 8, 2007
Answered

Create XML

  • January 8, 2007
  • 5 replies
  • 1065 views
I have a flash Slideshow that gets its data from an xml page.

I can I use coldfusion to create the page on the fly. I will have a drop down box that wil tell what cateogry was chosen. Here is my xml page.

<gallery>
<!-- The line below sets the path to the folder where the images are stored -->
<setup path="images/">
<!-- The the following lines are used to customize the look of the gallery -->
<imgWidth>450</imgWidth>
<imgHeight>300</imgHeight>
<imgLink> http://www.yahoo.com</imgLink>
<thumbWidth>50</thumbWidth>
<thumbHeight>40</thumbHeight>
<transitionType>fade</transitionType>
<thumbnailRows>1</thumbnailRows>
<thumbPosition>left</thumbPosition>
<captionPosition>bottom</captionPosition>
<showControls>true</showControls>
<--This is the default pic -->
t6.jpg
<img>6.jpg
<caption>
xxx
</caption>
<-- These are the thumbnails -->

<item>
<thumb>1.jpg</thumb>
<img>11.jpg
<caption>xxx</caption>
</item>
</gallery>

I just need to know how to pass the variables to the XML page on the fly, I have not worked with this before so any help would be great.

Thanks
jim
    This topic has been closed for replies.
    Correct answer jazz823
    Ok,, here is what my xml output in IE looks like, below is the code that generates it. The upgrade to server 7 made a difference in the parce, but I can not get the setup path line to work right, the slash should be in the quotes.

    - <gallery>
    <setup path="images" />
    <imgWidth>450</imgWidth>
    <imgHeight>300</imgHeight>
    <thumbWidth>50</thumbWidth>
    <thumbCaptionChange>true</thumbCaptionChange>
    <thumbHeight>40</thumbHeight>
    <numberFont>verdana</numberFont>
    <numberFontSize>12</numberFontSize>
    <numberColor>WHITE</numberColor>
    <scrollSpeed>3</scrollSpeed>
    <transitionType>fade</transitionType>
    <thumbnailRows>1</thumbnailRows>
    <thumbPosition>left</thumbPosition>
    <captionPosition>bottom</captionPosition>
    <showControls>true</showControls>
    t1.jpg
    <img>1.jpg</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">This is the first Caption     </font>
    ]]>
    </caption>
    - <item>
    <thumb>t2.jpg</thumb>
    <img>image</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">Caption 2     </font>
    ]]>
    </caption>
    </item>
    - <item>
    <thumb>t3.jpg</thumb>
    <img>image</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">caption 3         </font>
    ]]>
    </caption>
    </item>
    </gallery>

    notice the setup path, has the slash outside the quotes.

    that seems to be the only issue.

    here is my code

    YESSSSSSS

    here is the working code. I had the setup close tag in the wrong place and was missing an item tag around the first image.

    Thanks for all your help

    5 replies

    Inspiring
    March 6, 2007
    Opening XML in Internet Explorer is a great way to quickly check the
    well-formedness of your XML document.

    Firefox is pretty good, especially since Firefox will tell you why an
    error exists, where as IE (6.x) just says, "I can't handle this line, bye".
    Inspiring
    March 6, 2007
    Nothing jumps out at me. On a housekeeping note, I would recommend using <cfsavecontent> instead of multiple <cfset>s. That will save tons of headaches when you have to go back to maintain your code.

    When you say the page does not process the XML, what do you mean?

    Have you tried opening the file in IE and see if it displays correctly? Opening XML in Internet Explorer is a great way to quickly check the well-formedness of your XML document.
    jazz823Author
    Inspiring
    March 8, 2007
    It acts as though it is not an xml file.

    I have 2 files, the original xml document. If i use it the slideshow loads.

    the new dynamic xml file i create looks identical to it, yet the slideshow does not load the images.

    It is like the xml content is being show as a different file type. I just upgraded to CF7 so I am going to see if that helps.
    jazz823Author
    Inspiring
    March 8, 2007
    Ok,, here is what my xml output in IE looks like, below is the code that generates it. The upgrade to server 7 made a difference in the parce, but I can not get the setup path line to work right, the slash should be in the quotes.

    - <gallery>
    <setup path="images" />
    <imgWidth>450</imgWidth>
    <imgHeight>300</imgHeight>
    <thumbWidth>50</thumbWidth>
    <thumbCaptionChange>true</thumbCaptionChange>
    <thumbHeight>40</thumbHeight>
    <numberFont>verdana</numberFont>
    <numberFontSize>12</numberFontSize>
    <numberColor>WHITE</numberColor>
    <scrollSpeed>3</scrollSpeed>
    <transitionType>fade</transitionType>
    <thumbnailRows>1</thumbnailRows>
    <thumbPosition>left</thumbPosition>
    <captionPosition>bottom</captionPosition>
    <showControls>true</showControls>
    t1.jpg
    <img>1.jpg</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">This is the first Caption     </font>
    ]]>
    </caption>
    - <item>
    <thumb>t2.jpg</thumb>
    <img>image</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">Caption 2     </font>
    ]]>
    </caption>
    </item>
    - <item>
    <thumb>t3.jpg</thumb>
    <img>image</img>
    - <caption>
    - <![CDATA[ <font size="14" color="#FFFFFF" face="verdana">caption 3         </font>
    ]]>
    </caption>
    </item>
    </gallery>

    notice the setup path, has the slash outside the quotes.

    that seems to be the only issue.

    here is my code
    Inspiring
    March 5, 2007
    I don't see anything obviously wrong with the code you posted. Have you tried opening the created XML file in IE to check the well-formedness of the document. XML does not allow certain characters (<.>, and &) so make sure any illegal characters are replaced with the HTML entity values (&lt;, &gt;, &).
    jazz823Author
    Inspiring
    March 5, 2007
    Thanks for all the help, The info now is being entered manually, I was going to set it up so that they can fill out a form, that data will then go into the db and then create the xml file. I know how to do the form and so on, I was just not sure on the syntax of the xml creation. I am going to try using some of the sample code that was added.

    Thanks
    JIm
    jazz823Author
    Inspiring
    March 6, 2007
    Ok, this code works like a charm and creates my file. However their seems to be some type of encoding missing as the page does not process the xml file even though it looks identical to one that works.

    I have attached the code, anything jump out at anyone?
    Inspiring
    March 2, 2007
    It looks like for each image, you are going to need to know
    3 things:
    1) the URL of the thumbnail
    2) the URL of the original image
    3) Caption data

    Is all that data coming from a form or a database? Once a user selects the images he/she wants, where does the additional information come from?

    Also, from first glance, it looks like the xml document is not well-formed. XML requires all tags to be completed (or closed) and properly nested. Where as you might be able to get away with the following in HTML due to the flexibility of the web browsers:

    <p> some text <b> bold text <i>italic</b></i><br>
    <p> some other text

    properly formed XML requires all tags to be nested correctly and closed:
    <p> some text <b> bold text <i>italic</i></b> <br/></p>
    <p> some other text </p>
    Inspiring
    January 8, 2007
    You can generate the XML in 2 ways (depending on the restrictions placed on you by your slideshow application).

    1) The easy way - build a coldfusion page that generates the XML text and then point your slideshow tool to your new CFM page instead of an XML document. You may have to play around with <cfcontent> to set the correct MIME type (I think its text/xml).
    a. Use <cfsetting enablecfoutputonly="Yes">
    b. Create your XML in a <cfsavecontent> block
    c. Set the document MIME type with <cfcontent>
    d. Output your XML

    2) If for some reason you absolutely, have to have an XML file to run your slideshow off of, you can following steps a-b above and then write your XML to a file using <CFFILE>

    Hope that helps.
    jazz823Author
    Inspiring
    January 9, 2007
    Hi, thanks for the ideas. I need to look around for some sample code. The slideshow does need the xml, but creating the lines of text is just something I have not done with cf before. So it should not be too bad. I just need to create a file called content.xml in that file I need to add the paramaters.

    Thanks I will google for some samples. Thanks
    Jim
    jazz823Author
    Inspiring
    March 2, 2007
    I have attached the xml file I am trying to create. I will have a form that allows the selection of the thumbnails and images, I want to have that form date creat and xml file like the one attached. I am not sure of the proper syntaxt.

    Thanks
    Jim