Hi
I am trying to import a XML file into Indesign CC2018 and then have the information from that update
a property called “Studio Artist” with a value of “M”, the property called “Studio Artist” already
has a value in it which is this “:”, I have managed to bring in the “JobSpecification”, but cannot figure
out how to have the value update from “:” to “M”
This is the XML file:
This is the script:
tell application "Adobe InDesign CC 2018"
set myJobPath to "HD:Users:Budgie:Desktop:mechspec.xml"
set myDoc to active document
(import XML myDoc from myJobPath)
-- how to have the value update from ":" to "M" ?
end tell
Hi, Budgie. If you want to do this in InDesign, the method requires you to know the XML item’s address, as in my sample code below. You could potentially probe all XML elements until a value is encountered. I wrote a script several years ago that did that, but it appears to be non-functioning at this time; perhaps it was specific to an even older version.
tell application "Adobe InDesign CS3"'s document 1
set XML element 1's XML element 1's XML element 1's XML attribute "value"'s value to "M"
end tell
Thanks for the insight, I’m probably trying to implement your suggestion incorrectly, as I cant
seem to get it to work, below is what I thought was right, but nothing happens so I guess it’s not.
The XML import definitely adds the property “Studio Artist” and the “Value” of “:”
I get the error:
tell application "Adobe InDesign CC 2018"
set myJobPath to "HD:Users:Budgie:Desktop:mechspec.xml"
set myDoc to active document
(import XML myDoc from myJobPath)
set XML element 1's XML element 1's XML element 1's XML attribute "Studio Artist"'s value to "M"
end tell
Hi. That was really just an example. I stated that you would need to know the address; i.e. determine it—which requires probing the structure’s various branches. In loading your XML, the actual address is a bit further down, and I’m not seeing the conditions described in your question. There is no “:” value anywhere to be changed. “Property” is an attribute name with “Studio Artist” as its value.
tell application "Adobe InDesign CS3"'s document 1 to set XML element 1's XML element 1's XML element 2's XML element 1's XML attribute "Property"'s value to "Studio Artist or M or whatever"
I’m not sure what you’re ultimately doing. If the XML isn’t already associated with document elements, I would probably advise against using InDesign to change the structure, because finding these lengthy object references more than a few times is going to be a horror show.