Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

find the XML Element [<email>]

New Here ,
Feb 07, 2010 Feb 07, 2010

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

TOPICS
Scripting
3.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Feb 07, 2010 Feb 07, 2010

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

Translate
Contributor ,
Feb 07, 2010 Feb 07, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 07, 2010 Feb 07, 2010

Thanks Ram,

Your code is fine. But i need rename the email tag into mail.

How to to this???

RAJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 07, 2010 Feb 07, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 07, 2010 Feb 07, 2010

Now its working fine. Thank you so much Ram.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 07, 2010 Feb 07, 2010

Hi All,

I need one more clarification. how to move the selected XML-Element to before its parent element?

Thanks, RAJ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 07, 2010 Feb 07, 2010

Hi Raj,


After selection the Element, try the below code:


var myElement = app.selection[0];

myElement.move(LocationOptions.before, myElement.parent);


Regards,

Ramkumar .P

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2013 Jul 25, 2013

Gdv

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 18, 2016 Feb 18, 2016

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

Screen Shot 2016-02-18 at 10.05.25 PM.png

Step: 2


I want added in the following attribues - ul list

Screen Shot 2016-02-18 at 10.05.44 PM.png

Advanced thanks friends and TPK,

Thanks,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 19, 2016 Feb 19, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 13, 2017 Jan 13, 2017

Dear Ram,

Could you help me, How to change tags of selected objected?

Screen Shot 2017-01-13 at 5.38.49 pm.png

Here is my code, that is not working.

app.selection[0].markup = app.activeDocument.xmlTag.item("Artifact");

Sumit

-Sumit
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 13, 2017 Jan 13, 2017

Have you even looked at the doc ?

InDesign ExtendScript API (10.0)

cf markupTag…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 14, 2017 Jan 14, 2017

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

-Sumit
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 16, 2017 Jan 16, 2017
LATEST

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']" );

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines