Highlighted

Select xml element in structure pane by javascript

Contributor ,
Dec 25, 2016

Copy link to clipboard

Copied

Dear All,

Is it possible to select multiple xml elements with their names in structure pane with js?

Below is my attachment:

structure pane.PNG

I have a script that select only one element, _p or _img. I need to select all tags except "Article" tags.

var doc = app.activeDocument;

var rt = doc.xmlElements[0];

var _p = rt.xmlElements.item("_p");

var _img = rt.xmlElements.item("_img");

_p.select();

_img.select();

Thanks,

Sumit

var doc = app.activeDocument; 

var rt = doc.xmlElements[0];

var allButArticle = rt.evaluateXPathExpression (".//*[name()!='Article']" );

if ( allButArticle.length ) app.select ( allButArticle );

Topics

Scripting

Views

1.5K

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

Select xml element in structure pane by javascript

Contributor ,
Dec 25, 2016

Copy link to clipboard

Copied

Dear All,

Is it possible to select multiple xml elements with their names in structure pane with js?

Below is my attachment:

structure pane.PNG

I have a script that select only one element, _p or _img. I need to select all tags except "Article" tags.

var doc = app.activeDocument;

var rt = doc.xmlElements[0];

var _p = rt.xmlElements.item("_p");

var _img = rt.xmlElements.item("_img");

_p.select();

_img.select();

Thanks,

Sumit

var doc = app.activeDocument; 

var rt = doc.xmlElements[0];

var allButArticle = rt.evaluateXPathExpression (".//*[name()!='Article']" );

if ( allButArticle.length ) app.select ( allButArticle );

Topics

Scripting

Views

1.5K

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
Dec 25, 2016 0
Valorous Hero ,
Dec 26, 2016

Copy link to clipboard

Copied

var doc = app.activeDocument; 

var rt = doc.xmlElements[0];

var allButArticle = rt.evaluateXPathExpression (".//*[name()!='Article']" );

if ( allButArticle.length ) app.select ( allButArticle );

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
Reply
Loading...
Dec 26, 2016 2
Contributor ,
Dec 26, 2016

Copy link to clipboard

Copied

Thank you so much Loic!

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
Reply
Loading...
Dec 26, 2016 0
Contributor ,
Dec 26, 2016

Copy link to clipboard

Copied

Dear Loic,

There is one issue, when I run this command next then select also every Item of under Article Tag.

Below is my scenario.

Screen Shot 2016-12-26 at 3.21.44 PM.png

I do not need to select any element under Article also.

My complete script is here:

app.scriptMenuActions.itemByID(78815).invoke(); 

var doc = app.activeDocument;

var rt = doc.xmlElements[0];

var allButArticle = rt.evaluateXPathExpression (".//*[name()!='Article']" );

if ( allButArticle.length ) app.select ( allButArticle );

try{ 

app.scriptMenuActions.itemByID(78818).invoke(); 

}catch(e){$.writeln(e.message)};

//}

Regards,

Sumit

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
Reply
Loading...
Dec 26, 2016 0
Valorous Hero ,
Dec 30, 2016

Copy link to clipboard

Copied

app.scriptMenuActions.itemByID(78815).invoke();   

 

var doc = app.activeDocument;  

var rt = doc.xmlElements[0]; 

var allButArticle = rt.evaluateXPathExpression ("./*[name()!='Article']" ); 

if ( allButArticle.length ) app.select ( allButArticle ); 

 

try{   

app.scriptMenuActions.itemByID(78818).invoke();   

}catch(e){$.writeln(e.message)};

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
Reply
Loading...
Dec 30, 2016 2
Contributor ,
Dec 30, 2016

Copy link to clipboard

Copied

Thank you Loic,

Yes your code working great!

Regards,

Sumit

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
Reply
Loading...
Dec 30, 2016 0
Loic_H LATEST
Community Beginner ,
Apr 14, 2020

Copy link to clipboard

Copied

Hello, this question is really late, but do you know how I may select a XML tag in the story.

I need to import an XML file with specific tags on words, and to be able to generate shape around those words, I need to get their bounds.

I cannot find any example, and the lack of documentation conducted me here.

Thanks in advance.
Loïc (me too)

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
Reply
Loading...
Apr 14, 2020 0