Skip to main content
Participating Frequently
December 3, 2019
Answered

XMP : Remove a nod from InDesign metadata

  • December 3, 2019
  • 2 replies
  • 852 views

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.

This topic has been closed for replies.
Correct answer Sunil Yadav

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

2 replies

Sunil Yadav
Sunil YadavCorrect answer
Brainiac
December 3, 2019

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

Participating Frequently
December 3, 2019

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

Jongware
Community Expert
December 3, 2019

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.