Skip to main content
Americo Pinto
Inspiring
March 16, 2021
Answered

How to retrieve a story by any associatedXMLElement

  • March 16, 2021
  • 1 reply
  • 672 views

Hi everyone,

 

i try to retrieve an all xml story on the xml structure of an InDesign document by clickinf a textframe that  I know the associatedXMLElement ; It is possible

 

see example please

So, I click on the textframe on the InDesign document and get his associatedXMLElement (the markupTag name "texte"), then I want to get the parent node "doc" but I only the retrieve the "root" node ; after this I want iterate through the all node "doc".

 

help is welcome, thanks

 

Américo

This topic has been closed for replies.
Correct answer Sunil Yadav

Try this:

if(app.selection[0].constructor.name == "TextFrame"){
    var docNode = app.selection[0].associatedXMLElement.parent.parent;
    for(var i = 0; i < docNode.xmlElements.length; i++){
        $.writeln(docNode.xmlElements[i].name)
        }
    }

Best

Sunil

1 reply

Sunil Yadav
Sunil YadavCorrect answer
Legend
April 7, 2021

Try this:

if(app.selection[0].constructor.name == "TextFrame"){
    var docNode = app.selection[0].associatedXMLElement.parent.parent;
    for(var i = 0; i < docNode.xmlElements.length; i++){
        $.writeln(docNode.xmlElements[i].name)
        }
    }

Best

Sunil

Americo Pinto
Inspiring
April 18, 2021

Hello Sunil,

 

I'm sorry this returns "undefined" and I'm looking for the associatedXMLElement

 

Regards