The item index requested for 'mytrimh' is "-9" (minus 9). Is that as intended?
After fixing that, this will fail next:
myDoc.documentPreferences.pageWidth = "mytrimh";
"pageWidth" accepts a "Measurement Unit (Number or String)". Of course, the string should be in a valid format for a measurement unit. The string "mytrimh" is not a valid value in any measurement unit. You probably intended this without the quotes.
I have changd it to
var myDoc = app.activeDocument
var mytrimh = myDoc.xmlElements.item(0).xmlElements.item(0).xmlElements.item(9);
var mytrimw = myDoc.xmlElements.item(0).xmlElements.item(0).xmlElements.item(10);
myDoc.documentPreferences.pageWidth = mytrimh;
myDoc.documentPreferences.pageWidth = mytrimw;
but still get the samee error - "No data available of the requested type"
Yes, -9 was not intended
This might indicate there are no 'item(9)' and/or 'item(10)' in your xml structure. This requires some debugging; check, for example, how many sub-elements there are in the first child of the root. Your script expects at least 11 sub-elements here, numbered 0 to 10.
You also may want to check if 'mytrimh' and/or 'mytrimw' actually get set to something (and, in case they are, to what).
mytrimh' and/or 'mytrimw' return contents = 250.00 and contents = 169.00 as per my original xml and Tags in InDesign
Hmm hm hm.
Perhaps the problem is this: xmlElements(x).item(y) returns an object of type "XmlItem", and pageWidth/pageHeight expect a string or number.
So, try this next
myDoc.documentPreferences.pageWidth = Number(mytrimh);
-- forcing the XmlItem to a Number representation.
Nearly there, I now get the page size adjusting but the size shows as "NaN"
Seems you are getting closer
try ...= parseInt(mytrimh);
I had tried that after trying Number(mytrimh); but it causes the same issue, ie the page size shows as "NaN". Would it help if you had my full script and the xml?
Let's dig a bit deeper.
I bet 'mytrimh' still is an "XmlElement" -- you can check by inserting this somewhere:
Try accessing the 'contents':
myDoc.documentPreferences.pageWidth = Number(mytrimh.contents);
That's it, thanks so much for your help.Iit works if it is still an XML element or not, as I tried
var mytrimh = myDocument.xmlElements.item(0).xmlElements.item(0).xmlElements.item(9).xmlContent;
This changed it to text, but both worked with = Number(mytrimh.contents);