6 Replies Latest reply on Jan 16, 2008 11:38 AM by Greg Dove

    Changing XML format to accept HTML tags

    Handycam Level 1
      I've inherited an old project from someone. It's a slide show that loads an XML file that contains all the slide info (image, audio, caption, etc.).

      The problem is that the image captions now need to contain HTML formatting codes (i,b,u) and the way the XML file was structured doesn't allow for this. The developer used attributes for this information, as in:

      <image path="99928009_01.jpg" title="Camaro" caption="A hot car makes a comeback" audio="99928009_01.mp3"/>

      I'm assuming I need more like

      <image path="99928009_01.jpg" title="Camaro" audio="99928009_01.mp3">
      <caption><![CDATA[A <b>hot</b> car makes a comeback]></caption>


      If so, how can I easily modify the code to now look for the new "caption" child node? The developer currently has:

      var imageNode = root.lastChild;
      var s=0;
      while (imageNode.nodeName != null) {
      imageData = new Object;
      var str:String = imageNode.attributes.path;
      tar = str.split(".");
      ttxt = tar[0]+"_thm."+tar[1];
      imageData.t = thumbpath+ttxt;
      imageData.audio = audiopath+imageNode.attributes.audio;
      imageData.path = imagepath+imageNode.attributes.path;
      imageData.title = imageNode.attributes.title;
      if (imageData.title==null){
      imageData.caption = imageNode.attributes.caption;
      if (imageData.caption==null){
      imageNode = imageNode.previousSibling;

      I basically understand what he did here, loop through all the lastChild nodes and extract the attributes. But the XML example above makes <caption> the lastchild, so how do I loop and get the attributes from <image> AND the contents of <caption> and keep them associated??

      If this was E4X, I'd have no problem but the older method of dealing with XML always puzzled me a bit.