Skip to main content
Inspiring
January 17, 2013
Answered

rename attribute in XML

  • January 17, 2013
  • 1 reply
  • 1306 views

Hi All,

I want to rename attribute in the indesign document. I have not found any reference in this forum.

Below is the attribute appear in the structure palette in the Indesign Document:

//news[@north=n01]

And want to change above line to:

//news[@south=n01]

Only want to change attribute name not value.

Need help.

Thanks,

Mon

Message was edited by: designmon79

This topic has been closed for replies.
Correct answer absqua

var doc = app.activeDocument,

    elements = doc.xmlElements[0].evaluateXPathExpression("//news[@north='n01']"),

    i, l;

for (i = 0, l = elements.length; i < l; i++) {

    elements.xmlAttributes.item("north").name = "south";

}

Jeff

1 reply

absquaCorrect answer
Inspiring
January 17, 2013

var doc = app.activeDocument,

    elements = doc.xmlElements[0].evaluateXPathExpression("//news[@north='n01']"),

    i, l;

for (i = 0, l = elements.length; i < l; i++) {

    elements.xmlAttributes.item("north").name = "south";

}

Jeff

Inspiring
January 18, 2013

Thank you sooo much Jeff.

Thanks,

Mon

karthikS
Inspiring
February 20, 2016

Hi absqua,

I have run your coding but i get one error comment in my indesign file. I have attached my screenshot below in your reference. how to resolved this type of errors. help me friends.

Advance thanks,