Importing XML into InDesign

I am just getting started with AS and am having trouble. I can code with PHP and Javascript, but AS is very difficult for me. I have downloaded a PDF called “Applescript for absolute starters”. This pretty much make since to me. However when I get to using other Application everything is dark and mysterious.

Take for example the Adobe Indesign CS dictionary says:

So I use the following code:

tell application "InDesign CS"
	import XML "Macintosh HD:Users:username:Desktop:xml:file.xml"
end tell

And I get the following error:

Applescripting InDesign is dark and mysterious, and I’ve been applescripting for years. The dictionary and associated PDF docs aren’t the best. They short on examples. Some concepts have examples, others don’t.

You have to be VERY specific working with InDesign. The error you are getting is because the command is being directed to the application itself and not to an object within a document of InDesign.

Personally, I find InDesign frustrating to script. So, Good Luck.

Brad Bumgarner, CTA

Thank you for the help.

Here is what I did to get it to work

tell application "InDesign CS"
	set mydoc to active document
	import XML mydoc from "Macintosh HD:Users:username:Desktop:xml:filename.xml"
end tell

Of course now I have to modify it to be more dynamic