Skip to main content
Participant
August 8, 2013
Question

Help needed on listing out all tag names using XML Rules in ExtendScript(InDesign)

  • August 8, 2013
  • 1 reply
  • 1042 views

Given a document with elements already in place, I am looking for a snippet of code to walk down the XML tree only two levels

deep to printout the names of each of the tags (not attributes).  I am just using javascript in extendscipt to accomplish this.  Ultimately,

I want to provide this list in a checkbox dialog and use those checked items to develop a TOC.  This latter part, I have in place.

It is just the pushing of the tag element names into an array that seems to be cumbersome for me at this point.

Any shortcut snippets out there that someone can provide?

A shorter version of this request....Is there anyway to just list out all element.markupTag.name of an XML tree, not knowing the xpath naming?

Using "//*" obviously is not working....

This topic has been closed for replies.

1 reply

Vamitul
Legend
August 9, 2013

well..

Document.xmlTags.everyItem().name will get you a array of all the xml tags in the document. Maby that will help you?

another way, and you can use it recursively:

myObject.xmlElements.everyItem().markupTag.name

will get you an array of tag names. use something like: http://stackoverflow.com/a/15806501 to remove duplicates.. and.. enjoy

Participant
August 9, 2013

Awesome.  The .everyItem() was exactly what I needed.  Thank you VERY much.  Any recommendations on a better reference would be appreciated.  I thought

I poured through the extendscript reference, but missed this if it was in there.

Regardless...you got me on track again.

Vamitul
Legend
August 12, 2013

http://jongware.mit.edu/idcs5/

jongware also has somwhere on the site a CHM file containing the documentation. One of the best resources ever!