Skip to main content
4everJang
Legend
March 19, 2012
Question

Finding an element from a text location

  • March 19, 2012
  • 1 reply
  • 937 views

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

This topic has been closed for replies.

1 reply

Known Participant
April 30, 2014

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

4everJang
4everJangAuthor
Legend
April 30, 2014

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