🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #14909

Re: [JS] Iterate through all XML elements in the active document?

#14909
From: Alan_Stearns
Date: Fri, 09 Jan 2004 01:06
23 lines
1264 bytes
Here's a sample script that might get you started. It worked for me on a simple test, but no guarantees...



 
firstElement = app.activeDocument.xmlElements.item(0);

processElement(firstElement);

function processElement(thisElement) 
{ 
	//call this recursively for all child elements 
	for (i=0; i<thisElement.xmlElements.length; i++) 
	{ 
		processElement(thisElement.xmlElements.item(i)); 
	}

	//do the thing you need to do to each element here: 
	if (thisElement.markupTag.name == "whatever") 
	{ 
		thisElement.xmlAttributes.add("my", "thing"); 
	} 
} 
Technical Details
Message-ID: <2ccf3f22.6@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
References: <2ccf3f22.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,fe35846f9233a0b7
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2004-01-08 17:07:43 PST
From: Alan_Stearns@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Re: [JS] Iterate through all XML elements in the active document?
Message-ID: <2ccf3f22.6@webx.la2eafNXanI>
Date: Thu, 8 Jan 2004 17:06:12 -0800
References: <2ccf3f22.-1@webx.la2eafNXanI>
Lines: 23
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit