This is probably a very easy thing to do, but how do I change the text by XML tag ID in InDesign with AppleScript?
I found out that the XML tag ID is not the same as the text frame ID.
tell application "Adobe InDesign CS2"
tell document 1
set myTag to XML tag "blah"
set myTagID to id of myTag
end tell
-- do somethingµ
end tell
I’m by no means an expert in xml tags i use indesign but not this feature!
so not sure how good or how reliable this script will be but i’ve tried to explain in the comments what i’ve done.
it seemed to work for me!
in indesign i deleted every tag that was there and added the “Blah” tag for ease.
then i created a text frame with some text in it.
the text frame was then assigned to the “blah” tag.
tell application "Adobe InDesign CS3"
tell document 1
set t to name of markup tag of every XML element as string -- get name of xml tag in this case its {"blah"}
set xmltag to item 1 of t -- because its in a list its item 1 of that list its the only tag in there!
tell XML tag xmltag
set j to object reference -- get the reference to the object the tags attached to in this case the text frame id
end tell
set b to contents of every text frame whose markup tag of associated XML element is equal to j -- get the contents of the text frame whose text frame id is in the variable j
end tell
end tell
b -- whatever text is in the text frame
Thanks for that code, i modified it slightly to produce a text frame ID so I could change the contents. If anyone has a better way to write this code, please let me know.
tell application "Adobe InDesign CS2"
tell document 1
set t to "bob" -- set t to XML tag name, in this case bob
tell XML tag t
set j to object reference -- get the reference to the object the tags attached to in this case the text frame id
end tell
set _id to id of every text frame whose markup tag of associated XML element is equal to j -- set j to the id of associated text frame
tell parent story of text frame id _id
set contents to "Testing 1 2 3"
end tell
end tell
end tell