automatically adding xml markup tag to graphics in Indesign

:lol:See below for partial solution that’s not working perfectly. Need help, thanks.

I used an example that referenced text items to come up with this:

set tagName to "Image"

tell application "Adobe InDesign CC 2018"
	tell active document
		
		make XML element of first XML element with properties {markup tag:tagName}
		set graphicList to all graphics
		repeat with x from 1 to length of graphicList
			tell graphic x to markup using tagName
		end repeat
		
	end tell
	
end tell

All I want to do is create an xml tag (that part works), then assign it to every graphic in my document. Why does this script not work?

Okay, wait I stumbled guessed my way to this:

tell application "Adobe InDesign CC 2018"
	tell active document
		
		set x to make XML element of first XML element with properties {markup tag:tagName}
		
		set imageList to every rectangle
		repeat with i from 1 to number of items in imageList
			markup item i of imageList using x
			delay 5
		end repeat
		
	end tell
	
end tell

This should be working. I can markup each item individually without the repeat function, BUT in the ID doc only the last item is getting marked up with that tag.

Even tho the log shows it is working:

tell application "Adobe InDesign CC 2018"
	make with properties {markup tag:"Image"} at XML element 1 of active document new XML element
		--> XML element id 101 of XML element id 2 of document id 2
	get every rectangle of active document
		--> {rectangle id 228 of spread id 200 of document id 2, rectangle id 221 of spread id 200 of document id 2, rectangle id 272 of spread id 254 of document id 2, rectangle id 266 of spread id 254 of document id 2}
	markup rectangle id 228 of spread id 200 of document id 2 using XML element id 101 of XML element id 2 of document id 2
	markup rectangle id 221 of spread id 200 of document id 2 using XML element id 101 of XML element id 2 of document id 2
	markup rectangle id 272 of spread id 254 of document id 2 using XML element id 101 of XML element id 2 of document id 2
	markup rectangle id 266 of spread id 254 of document id 2 using XML element id 101 of XML element id 2 of document id 2
end tell

Hi. My understanding is that same-named tags aren’t shared; each one is an instance. Your method may just be moving the target.

tell application "Adobe InDesign CS3"'s document 1 to repeat with anObject in rectangles
	make XML element at XML element 1 with properties {markup tag:"whatever", XML content:anObject}
end repeat

Thank you that did the trick.