How to change Tag Element Name in xml structure?
Hi Everyone,
I want to change tag name after creating tag through scripting.

Thank you.....
Hi Everyone,
I want to change tag name after creating tag through scripting.

Thank you.....
Ahh, my bad i did not look into it deeply. Well your case would fail if the selection is a textframe as mine would if the selection is a text. So a more appropriate code that handles both the cases would be
var newItem = app.activeDocument.xmlTags.itemByName("Name")
if(newItem.isValid)
{
var a;
try{
a = app.selection[0].associatedXMLElements[0]
}catch(e){}
try{
if(!a)
a = app.selection[0].associatedXMLElement
}catch(e){}
if(a)
a.markupTag = newItem
}
The idea is simply to use try catch block to see if the property exists or not, this should also cater to selection not being tagged as well.
-Manan
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.