Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to select text of child element of graphic element(adobeinDesign)using applescript or Javascript

Guest
Jun 27, 2013 Jun 27, 2013

hai all,

How to select text of child element of graphic element(adobeinDesign)using applescript or Javascript

TOPICS
Scripting
2.1K
Translate
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
Enthusiast ,
Jun 28, 2013 Jun 28, 2013

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.

Translate
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
Guest
Jun 30, 2013 Jun 30, 2013

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 !

Translate
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
Enthusiast ,
Jul 01, 2013 Jul 01, 2013

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

Translate
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
Guest
Jul 01, 2013 Jul 01, 2013

hi,

      sample 1 works good,sample 2 it doesnt work .

I am wants to select text of alt-text xml element .

Translate
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
Guest
Jul 01, 2013 Jul 01, 2013

Translate
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
Guest
Jul 01, 2013 Jul 01, 2013

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

Translate
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
Guest
Jul 01, 2013 Jul 01, 2013

Screen Shot 2013-07-02 at 9.47.57 AM.pngsee this image Andreas , this is the xml elements , i am wants to traverse & select text of alt-text xml elements !!!!!!!!!!!!!!

Translate
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
Enthusiast ,
Jul 04, 2013 Jul 04, 2013
LATEST

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

Translate
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