Here's a bit of code for getting an XMP value out of a document. If it's complex, you have to do a bit more work.
Internally, it handles ISOSpeedRating. For UsageTerms, you could do something like this:
Code: Select all var str = getXMPValue(app.activeDocumet, "UsageTerms");
if (!str) {
return;
}
var xml = new XML(str);
var cr = xml.*::Alt.*::li;
var terms = cr.toString();
Here's the function:
Code: Select all//
// Get the XMP value for (tag) from the object (obj).
// obj can be a String, XML, or Document. Support for
// Files will be added later.
//
// Based on getXMPTagFromXML from Adobe's StackSupport.jsx
//
function getXMPValue (obj, tag) {
var xmp;
if (obj.constructor == String) {
xmp = new XML(obj);
} else if (obj.typename == "Document") {
xmp = new XML(obj.xmpMetadata.rawData);
} else if (obj instanceof XML) {
xmp = obj;
// } else if (obj instanceof File) {
// add support for Files
} else {
Error.runtimeError(19, "obj");
}
var s;
// Ugly special case
if (tag == "ISOSpeedRatings") {
s = String(xmp.*::RDF.*::Description.*::ISOSpeedRatings.*::Seq.*::li);
} else {
s = String(eval("xmp.*::RDF.*::Description.*::" + tag));
}
return s;
};