🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #8085

Searching for XML tags in Applescript

#8085
From: Malcolm_Whild
Date: Sun, 05 Nov 2006 21:29
30 lines
1817 bytes
Hi all,

I'd appreciate some help please in dealing with an xml file that I've imported into ID CS2.

I'd like to be able to search for a specific tag, check to see what its parent tag is (if any) and style the text accordingly.

tell application "Adobe InDesign CS2"
	activate
	if (count documents) = 0 then
		display dialog "You must have an InDesign document open to use this application!" buttons " OK " default button 1 with icon caution
		return
	else
		set find preferences to nothing
		set change preferences to nothing
		tell document 1
			set myTag to XML tag "para"
			set myStyle to paragraph style "body text"
			search with find attributes {XML tag:myTag} with change attributes {applied paragraph style:myStyle}
		end tell

	end if
end tell

I had hoped that this first attempt would find the <para> tag and apply my paragraph style to the text. I have tried telling the text of the document instead of the document itself, but still no joy.

I based this script on a previously successful one that I wrote for searching for bold and italic etc and applying character styles to the text. I must admit that I find the applescript dictionary and documentation pretty heavy going and quite short on examples.

Thanks heaps,

Mal
Technical Details
Message-ID: <3bc22fe2.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.isoc.lu!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,3b9ef15d95a2b313,start
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Malcolm_Whild@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news2.volia.net!news.ecp.fr!news.isoc.lu!webcrossing
Newsgroups: adobe.scripting.indesign
Subject: Searching for XML tags in Applescript
Message-ID: <3bc22fe2.-1@webcrossing.la2eafNXanI>
Date: Sun, 5 Nov 2006 13:29:14 -0800
Lines: 39
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit