Skip to content

Instantly share code, notes, and snippets.

@osima
Created June 3, 2010 06:20
Show Gist options
  • Save osima/423546 to your computer and use it in GitHub Desktop.
Save osima/423546 to your computer and use it in GitHub Desktop.
InDesignのXMLへのアクセス
//
// InDesign ドキュメントのXMLツリーから 要素 "Image" を探し出し、その position 属性の値を表示.
//
function procImage( eImage ){
var attrs = eImage.xmlAttributes
for(var i=0; i<attrs.length; i++){
var attr = attrs.item(i);
if( attr.name == 'position' ){
alert( attr.value );
}
}
}
function trace( xmlele ){
for( var i=0; i<xmlele.xmlElements.count(); i++){
var e = xmlele.xmlElements.item(i);
if( e.markupTag.name == 'Image' ){
//alert( e.markupTag.name );
procImage( e );
}
trace( e );
}
}
var doc = app.activeDocument;
var eRoot = doc.xmlElements.itemByName("Root");
trace( eRoot );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment