1 Reply Latest reply on Nov 15, 2010 9:39 AM by JohnDevlon

    [CS4][JS] How to detect the XMLelement type ?




      Can anyone please help me ?


      I've written a small loop that check's every XML element. I'm trying to find out if the XMLelement contains text so I can replace the text, or if the XMLelement is a image, so i can replace the image.


      Does anyone know how i can detect the XML element type?





        • 1. Re: [CS4][JS] How to detect the XMLelement type ?
          JohnDevlon Level 1

          Hi everybody,


          After some testing I found this solution :



          if(!( elm.xmlAttributes.item("href") == null)){

                   // if element contains href attribute, it must be a image tag


                  var myImageFullPatch = myImageFolder.fsName + "/" + myImageName;

                  var myRectangle = elm.xmlContent.parent;




          } else {

                 // Check if the element has text

                  if(!( elm.contents == null)){

                        // the element has text. Replace the text

                       elm.contents = myText;




          It works for me but is this the best solution ?