Skip to main content
Inspiring
May 11, 2009
Answered

howto change xml parent

  • May 11, 2009
  • 1 reply
  • 933 views

in my XML stucture, initially I have <Root> with 2 childs - <A> and <B>.

any script that can make <A> being the parent of B?

such that the final XML structure be <Root> is the parent of <A>, <A> is the parent of B.

please help... thank you

This topic has been closed for replies.
Correct answer srakete

Hi,

this should work:

var myDoc = app.activeDocument;

var myRootXmlElement = myDoc.xmlElements[0];

var myAXmlElement = myRootXmlElement.xmlElements.item("A");

var myBXmlElement = myRootXmlElement.xmlElements.item("B");

myBXmlElement.move(LocationOptions.AT_END, myAXmlElement);

Stefan Rakete

1 reply

srakete
sraketeCorrect answer
Inspiring
May 11, 2009

Hi,

this should work:

var myDoc = app.activeDocument;

var myRootXmlElement = myDoc.xmlElements[0];

var myAXmlElement = myRootXmlElement.xmlElements.item("A");

var myBXmlElement = myRootXmlElement.xmlElements.item("B");

myBXmlElement.move(LocationOptions.AT_END, myAXmlElement);

Stefan Rakete

Inspiring
May 12, 2009

GREAT! it worked!

THANKS a million...