2 Replies Latest reply on May 8, 2013 12:03 AM by vinothr82

    Determine page item type from xmlelement

    s.vnesh Level 1

      I have a page item (text frame or text on path) that has been tagged (say tag named pp).

      I need to determine if it is a text frame or text path using the xmlelement.

      Can anyone guide how to do this?


      I tried the following:

      var items = doc.xmlElements[0].evaluateXPathExpression("//pp");

      var story = items[0].parent.parentStory;

      story.pageItems.item(0).allPageItems.item(0).constuctor.name // this should be textframe or textpath


      But could not succed.


      Kindly help!

        • 1. Re: Determine page item type from xmlelement
          absqua Level 4



          var items = doc.xmlElements[0].evaluateXPathExpression("//pp");



          1 person found this helpful
          • 2. Re: Determine page item type from xmlelement

            items[0].xmlContent.textContainers[0].constructor.name may not work in all cases.

            For instance, if you have simply tagged the text in a text frame or a text path then

            items[0].xmlContent would return Text object for which textContainers property is not available.


            You could try the following:

            var xmlElems = doc.xmlElements[0].evaluateXPathExpression("//pp");

            var parentTF = xmlElems[0].texts.item(0).parentTextFrames[0];


            if(parentTF instanceof TextFrame)

            $.write ("Text Frame");

            else if (parentTF instanceof TextPath)

            $.write ("Text Path");