6 Replies Latest reply on Jul 24, 2010 8:43 AM by Loic.Aigon

    [JS] For info, xmlElement.contents may fool you (or not ;-) )

    Loic.Aigon Adobe Community Professional

      Hi,

       

      Just in case you didn't know, I noticed that when you grab contents from a Text which is tagged, the tags are considered as characters.

      I spend few hours trying to understand why 2 strings could have two different length.

       

      But if you have <paragraph>Bla</paragraph>, the length will be 5 and not 3

       

      To go quick "this contents" is a reference to a tagged text in the document.

       

      so compare this contents to "Bla" will throw false but these tags are invisible, meaning that alert( this contents) will display "Bla".

      It took me a while to figure that.


      So for the record, I could extract the content I was interested in, getting rid of teh tags without untagging like this :

      var reg=new RegExp("\uFEFF","gi");

      this contents .replace(reg,"");

       

      FYI.

       

      Loic