Copy link to clipboard
Copied
hai all,
How to select text of child element of graphic element(adobeinDesign)using applescript or Javascript
Copy link to clipboard
Copied
Hi Suripappu!
I don't understand what "text of child element" means in your question, or whether you are referring to XML elements or items on a page.
Anyway, perhaps this might help you, with the following code you can get the file name, with the rectangle "container" of an image selected:
app.activeDocument.selection[0].images[0].itemLink.name
Result: my_tiff.tif
Eps images has a collection of their own:
app.activeDocument.selection[0].epss[0].itemLink.name
Result: my_eps.eps
Best regards,
Andreas J.
Copy link to clipboard
Copied
hi Andreas ,
I ma not asking selection of image .
Example:
-- Image (Parent xml element)
--para ( child xml element to image)
Image is a parent xml element , that parent xml element of image having child element like para , i am wants to select that para xml element.
i am using rule processor to select para xml element , but it causes error.... Any Idea !
Copy link to clipboard
Copied
So "image" and "para" are just XML element names in the XML Struction, and the specific names are irrelevant?
So it's about finding and selecting nodes in the XML Structure? Here are some samples:
// Sample 1
var elemRoot = app.activeDocument.xmlElements[0]; // The first (root) xml element of th active document
var elem1 = elemRoot.xmlElements[0]; // the first child element of the root elem
var childElem = elem1.xmlElements[0]; // going down another level deeper... etc
childElem.select(); // Select the item using the select() method.
// Sample 2
allImageParaXmlElements = app.activeDocument.xmlElements[0].evaluateXPathExpression('//image/para');
allImageParaXmlElements[allImageParaXmlElements.length-1].select(); // Select the last of the para elements found
Copy link to clipboard
Copied
hi,
sample 1 works good,sample 2 it doesnt work .
I am wants to select text of alt-text xml element .
Copy link to clipboard
Copied
Copy link to clipboard
Copied
hi andreas,
inline-graphic xml elements have only one child xml element alt-text .
in this case , i am write code as,
allImageParaXmlElements = app.activeDocument.xmlElements[0].evaluateXPathExpression('//inline-graphic/alt-text');
allImageParaXmlElements[allImageParaXmlElements.length-1].select(); // Select the last of the para elements found
it causes error !!!!!!!!!!!!!!!...........
Regrads,
Suripappu
Copy link to clipboard
Copied
see this image Andreas , this is the xml elements , i am wants to traverse & select text of alt-text xml elements
!!!!!!!!!!!!!!
Copy link to clipboard
Copied
Do you want all "alt-graphics" under all "inline-graphic" elements in the whole XML structure?
Try to experiment with the query
allImageParaXmlElements = app.activeDocument.xmlElements[0].evaluateXPathExpression('//inline-graphic/alt-text');
The string following evaluateXPathExpression, is the "path" that you are looking for.
The "//" means that the whole document is searched, all levels (also slower).
Try it in the console window of the ExtendScript Toolkit first, so that you can see how many elements the XPath query returns. If there were no "hits", then row number two in my sample code would raise an error.
Have your tried to include the namespace "cl:" as part of the XMLElement names in your XPath query?
To get the name of the XMLElement, you could select the xml element and play around with "app.selection[0]", and write out its markupTag.name.
Andreas
Find more inspiration, events, and resources on the new Adobe Community
Explore Now