Skip to main content
Inspiring
December 19, 2014
Question

how to replace a Frame level XML element without deleting the child XML elements?

  • December 19, 2014
  • 1 reply
  • 392 views

how to replace a Frame level XML element without deleting the child XML elements?

I have a XML element on frame (say having tag name as 'Tag1'), and also there in inline XML elements on text inside frame (say having tag name as 'Tag2' and 'Tag3'). Please see below snapshot for details:


Now I need to replace the XML tag on Frame1 with "Tag4". But if I try to delete and create a new element, all the Child element will get removed from it.

If I try to rename the Tag1 to some other Tag name, then it will also get renamed on Frame2.

So how can I change the XML element on Frame1 keeping the child Tags intact in the hierarchy??

We can do this in Indesign by clicking on Frame1 and selecting the New tag from Tag hierarchy, I need to know how we can do this using C++.

can some one suggest something?

This topic has been closed for replies.

1 reply

Community Expert
December 29, 2014

Hi Aman,

You need to retag Frame1 with the new tag that you want, use the following method to do it

Utils<IXMLElementCommands>()->CreateElement()

Using this method the old tag on the frame will be removed and the new one will be applied keeping the child tags hierarchy intact. Your approach of deleting the node and renaming the tag correctly should not work. Please try this, for more details and to create a quick sample you can tweak the code in the Snippetrunner plugin, the method of your interest will be SnpManipulateXMLElements::TagStory()

Hope this helps.

Manan

-Manan
Inspiring
December 30, 2014

Thanks for the reply Manan.

Anyway, i tried with Utils<IXMLElementCommands>()->SetElement(), this is also working fine for me.