Copy link to clipboard
Copied
Hi All,
I am new to InDesign scripting.
I want to know how to find the XML Element [<email>] in n number of nested structure?
Give me any idea.
Thanks, RAJ
Hi RAJ,
See my updated code below:
var myDocument = app.activeDocument;
FindEmail(myDocument);
alert("process Completed");
function FindEmail(elm)
{
for (var i = 0; i < elm.xmlElements.length; i++)
{
XMLelementName=elm.xmlElements.markupTag.name.toString();
if(XMLelementName=="email")
{
elm.xmlElements.markupTag = "mail";
}
FindEmail(elm.xmlElements);
}
}
Regards,
Ramkumar .P
Copy link to clipboard
Copied
Hi RAJ,
For this kind of cases you need to use the recursive functions.
var myDocument = app.activeDocument;
FindEmail(myDocument);
function FindEmail(elm)
{
for (var i = 0; i < elm.xmlElements.length; i++)
{
XMLelementName=elm.xmlElements.markupTag.name.toString();
if(XMLelementName=="email")
{
elm.xmlElements.select();
alert(elm.xmlElements.contents.toString());
}
FindEmail(elm.xmlElements);
}
}
I hope this will help you.
Regards,
Ramkumar .P
Copy link to clipboard
Copied
Thanks Ram,
Your code is fine. But i need rename the email tag into mail.
How to to this???
RAJ
Copy link to clipboard
Copied
Hi RAJ,
See my updated code below:
var myDocument = app.activeDocument;
FindEmail(myDocument);
alert("process Completed");
function FindEmail(elm)
{
for (var i = 0; i < elm.xmlElements.length; i++)
{
XMLelementName=elm.xmlElements.markupTag.name.toString();
if(XMLelementName=="email")
{
elm.xmlElements.markupTag = "mail";
}
FindEmail(elm.xmlElements);
}
}
Regards,
Ramkumar .P
Copy link to clipboard
Copied
Now its working fine. Thank you so much Ram.
Copy link to clipboard
Copied
Hi All,
I need one more clarification. how to move the selected XML-Element to before its parent element?
Thanks, RAJ
Copy link to clipboard
Copied
Hi Raj,
After selection the Element, try the below code:
var myElement = app.selection[0];
myElement.move(LocationOptions.before, myElement.parent);
Regards,
Ramkumar .P
Copy link to clipboard
Copied
Gdv
Copy link to clipboard
Copied
Dear Ram & Tpk,
Dear Ram, Tpk and friends,
I need for help friends urgent.
I will looking for xml attributes deleted and added in xml element "ul" list.
Step; 1
I want deleted in the following attribues - ul list
Step: 2
I want added in the following attribues - ul list
Advanced thanks friends and TPK,
Thanks,
Copy link to clipboard
Copied
Dear friends,
Hi all java expert,
Please clarify my above problem by indesign Cs6. this help saved my life, help my friends,
Advance Thanks All.
Copy link to clipboard
Copied
Dear Ram,
Could you help me, How to change tags of selected objected?
Here is my code, that is not working.
app.selection[0].markup = app.activeDocument.xmlTag.item("Artifact");
Sumit
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Dear Ram,
Can I use && condition for attribute?
In my document there is many span tag but I wanted to change those tag which mach their attributes.
And also change there attributes.
Sumit
Copy link to clipboard
Copied
Hi Oriup,
You can use the "and" operator in two ways.
E4X
tag.(@name=='yo' && @id==123)
XPATH
evaluateXPathExpression ( "//tag[@name='yo' and @id='123']" );
Find more inspiration, events, and resources on the new Adobe Community
Explore Now