Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Find and Select text based on XML tag name.

Explorer ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Hi Team, 

 

I need to find a text and select based on XML tag name, EX:. snap shown in below.

 

BalajiMurugesan_0-1627377527463.png
Need to find "jrnlBidRef" and need to select the text.

Thanks

TOPICS
Scripting

Views

129

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 28, 2021 Jul 28, 2021
Hi Balaji, To ignore this pop-up, you try this snippet: app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT; var root = app.activeDocument.xmlElements[0]; var xrefRid = root.evaluateXPathExpression('//jrnlBidRef'); if(xrefRid.length){ if(xrefRid[0].xmlContent){ xrefRid[0].xmlContent.select(); } } If you turn off the interaction level, that alert will not appear. Generally this alert will come while evaluating xpath when some characters ...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Try the following, it will find and select the first element tagged with jrnlBidRef anywhere in the structure. You can tweak the xpath as per your needs.

var root = app.activeDocument.xmlElements[0];
var xrefRid = root.evaluateXPathExpression('//jrnlBidRef');
if(xrefRid.length)
{
	if(xrefRid[0].xmlContent)
		xrefRid[0].xmlContent.select()
}

-Manan

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Hi @Manan Joshi,

I am facing following error.

 

BalajiMurugesan_0-1627388587827.png

 

 

<span cstyle="jrnlQueryRef" data-citation-string=" AQ11" class="jrnlQueryRef" data-org-id="3af2824b-b168-49bc-9ff8-d55c2dafe00f" data-rid="b74ab7dc-52a6-441c-b9ec-4e5377816430" data-class="jrnlQueryRef" data-type="start" data-query-ref="true" data-query-for="author" data-query-from="copyeditor" data-channel="query" data-topic="action" data-event="click" data-message="{&apos;funcToCall&apos;: &apos;highlightQuery&apos;}" data-content-type="jrnlQueryRef" specific-use="start"></span>

 

Ex: need to find data-citation-string=" AQ11" or what ever tag in this structures tag and need to apply a character style.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Do you get this error using just my code in isolation? If i remember correctly such an error occurs when we try to write a string with special characters like say tag markers into an XML file. Can you share a sample InDesign file that has this issue with the code that i shared. Just selecting the text should not give this error in my opinion

-Manan

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Hi @Manan Joshi 

Sample file available in below file.

https://we.tl/t-HCj8J0hjPB

 

I need to find the "AQ" citation and create anchor text frame and content with the ciation like as below snap.

 

BalajiMurugesan_0-1627452526051.png

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 28, 2021 Jul 28, 2021

Copy link to clipboard

Copied

Hi Balaji,

To ignore this pop-up, you try this snippet:

 

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var root = app.activeDocument.xmlElements[0];
var xrefRid = root.evaluateXPathExpression('//jrnlBidRef');
if(xrefRid.length){
    if(xrefRid[0].xmlContent){
        xrefRid[0].xmlContent.select();
        }
    }

 

 

If you turn off the interaction level, that alert will not appear.

Generally this alert will come while evaluating xpath when some characters are available which InDesign can not convert it to XML. So for not showing this alert, turning Off Interaction level is the solution.

 

Best

Sunil 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 29, 2021 Jul 29, 2021

Copy link to clipboard

Copied

Hi Sunil,

Thanks for your information,

and i shared one sample file here, kindly check the sample and share any idea to select "AQ" and insert an anchor frame same as attached snap.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 01, 2021 Aug 01, 2021

Copy link to clipboard

Copied

Hi @Balaji Murugesan,

Sorry to be a bit blunt but this is not the way to use a forum. You posted a query and recieved a response for which you mentioned that you get an error. However on being provided with an explanation on why such an alert is shown and asking for more information on how you tried code etc. You did not respond with asked information but changed the question. How is creating an anchored textframe and populating it related with finding and selecting the text as mentioned in your intial post. You could have taken the original question to a logical conclusion and then if needed asked for additional suggestion on anchored textframe. To me it seems you change the question as per the requirement change in your current project. Sorry to say the only thing this does is populate the forum with inconclusive discussion which helps noone.

-Manan

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

Hi @Manan Joshi,

Extremly sorry,

All the my questions are releated my studies, 

 

1. I thought at an early stage, if the text can be selected by the XML tag, I know the code for inserting the anchor frames and required contents, which is why I raised these questions.

2. But all your answers are shown as zero in length.

3. So, if I share all the requirements, I was think it will be very helpful to solve my questions.

4. I still could not find anything wrong with my questions, my need may be due to low communication skills shown in other categories.

5. I thought the forum was an effective way to get an answer, But the answer affects my soul, for which I am very sorry.

6. Now I am afraid to use the forum, you have destroyed my way of thinking.

 

Thanks a lot.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

LATEST

Hi Balaji Murugesan,

 

You should not say such a thing. We all are here dedicated to help every other user reagrdless of their contry, their intention etc. The point that @Manan Joshi made is that this question is not only just for you, but people who are stuck with the kind of issue they can search & get solution to their problem.

 

So If this thread becomes long with counter question, other user seeking help might not able to figure out soultion.

So Instead of negative talk, you should learn from your seniors & pay attention to that & try to overcome your issues instead of blaming.

 

P.S. @Manan Joshi has been great help for tons of users over 10+ years. We all are greatful to have him here.

 

Best

Sunil

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines