0

I found this script which opens the complete structure of an InDesign doc.

var items = app.activeDocument.xmlElements.everyItem();
while( items.xmlElements.length ) {
    items = items.xmlElements.everyItem();
    app.select(items.getElements());
    if( items.xmlAttributes.length )
        app.select(items.xmlAttributes.everyItem().getElements());
}
app.select(null);

Being a novice in InDesign/javascripting, how can I achieve the opposite?
In other words collapsing the entire structure?
Thank you n

EDIT: In case the above doesn't make sense at all, I would like to add that my goal is to automate the closing of the entire tree of a document in the InDesign Structure pane by a script. Effectively "alt + click" on the root of the tree. How could I do that?

numbernine
  • 13
  • 6

2 Answers2

1

I can't see any properties or methods to call nor any trick that would collapse a XMLELement.

Loic
  • 2,173
  • 10
  • 13
0

How could I do that?

I once wrote a script that moved xml elements and noticed that as each element was moved, the child structure for that element was collapsed. So, with a script you could move the bottom element in a range of elements to the top and repeat for each element. The following AppleScript would collapse all children of the InDesign document's route element. The resulting order will be the same as the original order.

tell application "Adobe InDesign CS5"
    tell XML element 1 of document 1
        repeat (count of XML elements) times
            move last XML element to before first XML element
        end repeat
    end tell
end tell

jsx scripters: feel free to chime in with a jsx version.

user1754036
  • 396
  • 1
  • 6