2 Replies Latest reply on Apr 29, 2014 8:15 PM by 4everJang

    Finding an element from a text location

    4everJang Level 3

      Hello again,

       

      How do I get to an element from a text location ? As my document is structured I am always in an element, but there does not seem to be a way to get there easily. I tried doc.ElementSelection but that just gives me ivalid elements.

       

      Thanks for any pointer in the right direction

       

      Jang

        • 1. Re: Finding an element from a text location
          tracey.orso

          Hi Jang,

           

          Did you end up working this out? I'm trying to do the same thing now and looking for the answer....

           

          thanks,

           

          Tracey

          • 2. Re: Finding an element from a text location
            4everJang Level 3

            Hi Tracey,

             

            It turned out to be really simple: you can translate between text locations and element locations using two methods (one for each direction).

             

            var oTRange = oDoc.TextSelection;

            var oTLoc = oTRange.beg;                    /* beg and end are two TLoc objects, which will be the same

                                                                               if no text is selected */

             

            var oELoc = oDoc.TextLocToElementLoc( TLoc );

             

            Kind regards

             

            Jang