Copy link to clipboard
Copied
Hello,
Can anyone tell me how to delete a node from the Indesign metadatas?
var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.deleteProperty(EspaceXMP,"TEST[1]"); //doesn't work (XMPs.deleteProperty is not a function)
XMPs.removeProperty(EspaceXMP,"TEST[1]"); //doesn't work (XMPs.deleteProperty is not a function)Thank you.
Try this code for you reference:
var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"","");
//// To remove the property, pass an empty string.
Best
Sunil
Copy link to clipboard
Copied
You can't. metadataPreferences is not "XML", it is part of the document model: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#MetadataPreference.html
If you are trying to clear a property, find its DOM name and type and set it to [], "" or 0.
Copy link to clipboard
Copied
Try this code for you reference:
var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"","");
//// To remove the property, pass an empty string.
Best
Sunil
Copy link to clipboard
Copied
Thank you Sunil, You're solution almost works to remove the all property :
var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"TEST","");But you also give me the way to remove only one nod in the property :
var XMPs = app.activeDocument.metadataPreferences;
var EspaceXMP = "http://ns.adobe.com/xap/1.0/";
var ContainerXMP = "TEST";
XMPs.setProperty(EspaceXMP,"TEST[2]",""); //remove the second nod of TEST property.Thanks a lot
Find more inspiration, events, and resources on the new Adobe Community
Explore Now