Hi all,
I want to untag an xml element in indesign. so I have written the code which is given below.But I face some problem.That is the particular element(informal example) given to untag is getting untagged, but the further searching of xml element by the same name is existed there but it is not continuing the searching for that element and coming outside of the loop and showing the error, when it enters into the loop, it shows the error as can’t get every XML element. so anyone help me out to solve this error?
tell application “Adobe InDesign CS2”
tell active document
set theRoot to (item 1 of XML elements) – the root element
end tell
end tell
myLoopLoop(theRoot)
property myLoLoV : {}
property myHoHoV : {}
on myLoopLoop(myElement)
tell application “Adobe InDesign CS2”
tell active document
set moreElement to every XML element of myElement
repeat with x from 1 to (count of moreElement)
set em1 to item x of moreElement
select em1
if (name of markup tag of em1 is “informalexample”) then
display dialog “ok”
tell em1 to untag
–display dialog “ok”
end if
–tell em1 to untag
tell me to myLoopLoop(item x of moreElement)
end repeat
end tell
end tell
end myLoopLoop
Jacintha,
I don’t know if this helps or not. I was trying to do something similar to your script. As a matter of fact, I used your script as a starting point.
I ran into the same issue you had. In my script below I am not using a loop, but using some basic repeats.
I have a feeling you could adjust your code to take care of the issue. I would attempt to work on your script, but my applescript skill is very week. I hack my through a script every 4 or 5 months when someone needs one where I work. I am not a programer, just a designer
-Jeff
tell application "Adobe InDesign CS2"
tell active document
set theRoot to (item 1 of XML elements) -- the root element
set theElements to every XML element of theRoot
repeat with x in theElements
if (name of markup tag of x is not "aPNBox") and (name of markup tag of x is not "idline") and (name of markup tag of x is not "tagline") then tell x to untag
try
set y to every XML element of x
if (name of markup tag of x is equal to "aPNBox") then set theSubElements to every XML element of x
repeat with y in theSubElements
if (name of markup tag of y is not equal to "expirationdate") then untag y
end repeat
end try
end repeat
end tell
end tell
tell application "Adobe InDesign CS2"
tell document 1
delete unused tags
end tell
end tell