3 Replies Latest reply on Feb 23, 2013 4:24 AM by designmon79

    Anchored object in XML

    designmon79 Level 1

      Hi All,

       

      I am trying to select a xml TAG  <ital></ital> if it has anchored object. So that I can remove XML TAG from anchored object.

       

      The below code is working if there is no text between <ital> xml tag.

       

      Can anyone please help me to change this code to select the tag if it has anchored object.

       

      Want to untag if selected is not a string.

       

       

      if(ital[j].contents == "")

         {

                  ital[j].select()

                  alert("Selected");

                  exit();

                   return;

          }

       

       

       

       

      Thanks,

      Mon

        • 1. Re: Anchored object in XML
          designmon79 Level 1

          Need to untag below condition.

          ital.png

           

          please help.

          Mon

          • 2. Re: Anchored object in XML
            R-Bala-Krishnan Level 2

            Try:

            var myDoc = app.documents.item(0);

            getAllXMLElements(myDoc);

            function getAllXMLElements(elm){   

                      for(var i1=0; i1<elm.xmlElements.length; i1++){

                    if((elm.xmlElements[i1].markupTag.name == "ital") && (elm.xmlElements[i1].contents.match (RegExp('^\uFFFC$')) != null)){           

                            var goBack = elm.xmlElements[i1].parent;

                            elm.xmlElements[i1].untag();               

                            getAllXMLElements(goBack);               

                            }

                        else{

                            getAllXMLElements(elm.xmlElements[i1]);

                            }

                        }   

                    }

             

            --

            Thanks & regards,

            Balakrishnan R

            • 3. Re: Anchored object in XML
              designmon79 Level 1

              Thank you so much, Balakrishnan.