20 Replies Latest reply on Aug 25, 2016 4:18 AM by tpk1982

    Remove XML text markers

    tpk1982 Level 4

      Hi,

       

      My requirement is to remove XML text markers between xml tags. It is like symbol :: :: .

       

      It is already discussed in forum, link below:

       

      Help Need!

       

      But i need to remove it.

       

      1) If i removed means it effect xml structure?

       

      2) I tried with <FEFF> but not able to replace.

       

      Regards,

      Karthi

        • 1. Re: Remove XML text markers
          Level 1

          try this.

           

          var myOverrideType = OverrideType.ALL;

           

           

          app.findGrepPreferences.findWhat = "~b~b+";

          var found = app.activeDocument.findGrep();

          while(found.length--){

              RemoveEnterMark();

          }

          function RemoveEnterMark()

          {

              for(var i =0;i<found.length;i++)

              {

                  try{

                      var found1 = app.activeDocument.findGrep();      

                      app.select(found1[0].characters[0]);

                      app.menuActions.itemByID(272).invoke();

                      app.selection[0].clearOverrides(myOverrideType)

                  }

                  catch(e){}

                  }

              }

          • 2. Re: Remove XML text markers
            tpk1982 Level 4

            Thanks Karthik. Sorry it is not working. Nothing removed.

            • 3. Re: Remove XML text markers
              Level 1

              Its working for me. copy the script in to script path and run.

              • 4. Re: Remove XML text markers
                tpk1982 Level 4

                Really? Tried with script path, not working

                 

                Tried in CS6 and CC2014

                • 5. Re: Remove XML text markers
                  tpk1982 Level 4

                  Marks are like below:

                   

                  Screen Shot 2016-08-19 at 4.57.51 PM.png

                  • 6. Re: Remove XML text markers
                    Level 1

                    Sorry for my misunderstanding

                    • 7. Re: Remove XML text markers
                      tpk1982 Level 4

                      Hi,

                       

                      Is it any update for the question? With this marks i am not able to do scripting for find and replace method. It will be helpful if someone provide a solution.

                       

                      Regards,

                      Karthi

                      • 8. Re: Remove XML text markers
                        Laubender Adobe Community Professional & MVP

                        Hi Karthi,

                        did you try TEXT Search/Replace with <FEFF> ?
                        Not GREP Search/Replace…

                         

                        Regards,
                        Uwe

                        • 9. Re: Remove XML text markers
                          tpk1982 Level 4

                          Hi Uwe,

                           

                          Yes i tried in TEXT search method... It find but can't able to delete.

                           

                          Regards,

                          Karthi

                          • 10. Re: Remove XML text markers
                            Kai Rübsamen Level 4

                            It seems, that <FEFF> isn’t always the same taste. I’m also not able to delete those characters and they cannot be selected in the UI.

                             

                            The colon describes anything in InDesign where InDesign can’t find a own sign for it. In this special case, Karthi wants to remove xml-markers. So I tried this one:

                             

                            var x = curFound.associatedXMLElements[0];

                                x.remove();

                             

                            But then, everything is removed. Maybe not the expected solution ;-)

                            • 11. Re: Remove XML text markers
                              Dirk Becker Level 4

                              You'd use the untag() method to remove an XMLElement while keeping its contents.

                              For example the following snippet untags all stories while keeping other tags (unbound, or images).

                              The commented out line untags all inner elements while keeping those at story level.

                               

                              var elements = app.activeDocument.stories.everyItem().associatedXMLElement;

                              while( elements.length ) {

                                var xe = elements.pop();

                              // if( xe ) xe.xmlElements.everyItem().untag();

                                if( xe ) xe.untag();

                              }

                              • 12. Re: Remove XML text markers
                                tpk1982 Level 4

                                Hi All,

                                 

                                Thank you for the reply.

                                 

                                @Kai: May i know what you keep in curFound? Is it like below? But it is not working for me!!

                                 

                                var myDoc = app.activeDocument 

                                app.findTextPreferences = app.changeTextPreferences = null 

                                app.findTextPreferences.findWhat = "<FEFF>" 

                                var myFound = myDoc.findText(); 

                                var x = myFound.associatedXMLElements[0];

                                x.remove();

                                 

                                @Dirk: If i use the snippet you provided is useful to untag. But i need to keep XML tags. Removing tags are not allowed.

                                 

                                Regards,

                                Karthi

                                • 13. Re: Remove XML text markers
                                  Kai Rübsamen Level 4

                                  Karthi, please provide a testfile, with a exact description, what should be removed and what must stay in the doc. Thanks.

                                  • 14. Re: Remove XML text markers
                                    Laubender Adobe Community Professional & MVP

                                    tpk1982 wrote:

                                    Yes i tried in TEXT search method... It find but can't able to delete.

                                    Hi Karthi,

                                    then I suspect, that all the FEFF characters are XML-markers.


                                    Can you show a screenshot where you enabled "Show Tag Markers"?
                                    And the XML-Structure pane as well?

                                     

                                    //Show tag markers etc.pp:
                                    app.documents[0].xmlViewPreferences.properties =
                                    {
                                        showStructure : true,
                                        showTagMarkers : true,
                                        showAttributes : true,
                                        showTaggedFrames : true,
                                        showTextSnippets : true
                                    }
                                    


                                    I don't know, if you want to remove only some of the XML markers or all inside a story.
                                    ( Ah. You answered that already while I typed…)
                                    => You don't want to untag or remove XML markers.

                                     

                                    Hm. Maybe there are empty ones where there is no text between the two markers?

                                    Do you want to remove only these?

                                     

                                     

                                    Regards,
                                    Uwe

                                    • 15. Re: Remove XML text markers
                                      tpk1982 Level 4

                                      Hi,

                                       

                                      @Kai: Sorry I am not able to share the document.

                                       

                                      @Uwe: I attached the screenshot here. But when i copy the content into another new document it disappeared. Strange but not sure what that is !!

                                       

                                      Screen Shot 2016-08-25 at 2.09.49 PM.png

                                      I hope your guess is correct. The empty ones where there is no text between the two markers may cause the problem. But i am not allowed to delete those also. Because after sometime client may fill in that column.

                                       

                                      Thanks,

                                      Karthi

                                      • 16. Re: Remove XML text markers
                                        Laubender Adobe Community Professional & MVP

                                        I still do not get why you want to remove something.

                                        • 17. Re: Remove XML text markers
                                          tpk1982 Level 4

                                          Hi Uwe,

                                           

                                          I am doing various script work with this document. For example, i am going to delete a column in the table. This is working fine with normal document. But it is not working with XML based document.

                                           

                                          var myDoc = app.activeDocument;

                                          var stories = myDoc.stories.everyItem ().getElements ();

                                          var myFind = new Array();

                                          var flgsel=app.selection[0];

                                          var x=flgsel.contents.split('\t');

                                          var myColumn=prompt("Enter column number","");

                                          app.findGrepPreferences = null;     app.changeGrepPreferences = null; 

                                          app.findGrepPreferences.findWhat=x[myColumn-1];

                                          for (i=0; i<stories.length; i++){

                                          myFind[i] = stories[i].findGrep(true);

                                              for (j=0; j<myFind[i].length; j++){

                                              app.changeGrepPreferences.changeTo  ="";

                                              flgsel.changeGrep();

                                              }

                                          }

                                           

                                          I suspect it is because of that hidden marks.

                                           

                                          Thanks,

                                          Karthi

                                          • 18. Re: Remove XML text markers
                                            Laubender Adobe Community Professional & MVP

                                            Usually GREP Search should ignore XML markers in the text that should be searched through.
                                            But what if your search text contains any special characters?
                                            Is that your problem?

                                             

                                            What exactly is selected before you run your snippet?
                                            Does this selection contain any XML markers?

                                             

                                            If so:
                                            1. Duplicate the formatted text of your selection to a new story ( an added temporary text frame ).
                                            2. Remove all XML markers from that story, remove all <FEFF> characters of that story.
                                            3. Build your array flgsel on the contents of that story.
                                            4. Remove the temporary text frame.


                                            and then run your snippet.

                                             

                                            Regards,
                                            Uwe

                                            1 person found this helpful
                                            • 19. Re: Remove XML text markers
                                              tpk1982 Level 4

                                              Hi Uwe,

                                               

                                              Hope that trick will work. Yes when i am selecting content it contains XML markers in between

                                               

                                              Thanks,

                                              Karthi