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:
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 );
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 );
Copy link to clipboard
Copied
Thank you so much Loic!
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.
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
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)};
Copy link to clipboard
Copied
Thank you Loic,
Yes your code working great!
Regards,
Sumit
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)