JS: Finding & replacing a character with a certain para style

I'm scripting an automated indd -> PDF project and I need to minimise the user input.
To this end, I want to search and replace commas in a particular cell of a table (which are the only instances of a particular para style), and replace them with forced line breaks.
The script I have for another part of the XML import looks like this:
//Search the document for the umlauts and replaces them with macrons. I
app.findTextPreferences.findWhat = "Ï";
app.changeTextPreferences.changeTo = "Ī";
myDocument.changeText();
What do I add to a similar script to make it target only content whish has a particular para style? And will it be compatible with CS4, 5 and 5.5, i.e. be agnostic to nested styles etc?
Thanks in advance,
Simon.

Use app.findTextPreferences.appliedParagraphStyle:
app.findTextPreferences.appliedParagraphStyle = "my_style";
.. your snippet here ..
I bet there is a reset somewhere above your snippet:
app.findTextPreferences = null;
app.changeTextPreferences = null;
and it would be safest to insert this as well below your code, or else this particular setting will "stick" and also be applied to following replaces.
This command is virtually unchanged since CS3, CS4? So far it seems to work in every version since then. But either way it's inconsequential to your nested styles, as these can only be character styles.

Similar Messages

  • How to replace the '&' character with '&' in xi

    Hi,
    i need to replace the '&' character with ' &'.but i f i am converting it is displaying as '&' because internally '&' = '&'.
    beacuse of this it is not converting.
    is there any possiblity to change the  standard conversion in xi.

    Graphical mapping does not support special character like & , <,> to be mapped.
    You can encode & as and in UTF-8 only.
    if you want the special character to be used, Opt XSLT mapping with ISO-8859-1 encoding
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="ISO-8859-1"/>
    <xsl:template match="/">
    <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>
    How to Work with Character Encodings in Process Integration (NW7.0)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • Find Replace from Textfile with regex

    Hello.
    I'm wondering if anyone knows about an existing script that does a find/replace by list like the script "FindChangeByList.jsx" that comes with every InDesign installation.
    This consists of tow parts, the script itself with the functionality and a simple textfile where you have simple one-liners capable of find/replace with regex.
    the Textfile:
    //FindChangeList.txt
    //A support file for the InDesign CS4 JavaScript FindChangeByList.jsx
    //This data file is tab-delimited, with carriage returns separating records.
    //The format of each record in the file is:
    //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
    //Where:
    //<tab> is a tab character
    //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
    //findProperties is a properties record (as text) of the find preferences.
    //changeProperties is a properties record (as text) of the change preferences.
    //findChangeOptions is a properties record (as text) of the find/change options.
    //description is a description of the find/change operation
    //Very simple example:
    //text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.
    //More complex example:
    //text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".
    //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
    //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
    //as shown in the example below:
    //{findWhat:"\\s+"}
    grep          {findWhat:"  +"}          {changeTo:" "}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double spaces and replace with single spaces.
    grep          {findWhat:"\r "}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space And replace with single returns.
    grep          {findWhat:" \r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a space and replace with single returns.
    grep          {findWhat:"\t\t+"}          {changeTo:"\t"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double tab characters and replace with single tab characters.
    grep          {findWhat:"\r\t"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.
    grep          {findWhat:"\t\r"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all returns followed by a tab character and replace with single returns.
    grep          {findWhat:"\r\r+"}          {changeTo:"\r"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double returns and replace with single returns.
    text          {findWhat:" - "}          {changeTo:"^="}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all space-dash-space and replace with an en dash.
    text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all dash-dash and replace with an em dash.
    The script:
    //FindChangeByList.jsx
    //An InDesign CS5.5 JavaScript
    @@@BUILDINFO@@@ "FindChangeByList.jsx" 3.0.0 15 December 2009
    //Loads a series of tab-delimited strings from a text file, then performs a series
    //of find/change operations based on the strings read from the file.
    //The data file is tab-delimited, with carriage returns separating records.
    //The format of each record in the file is:
    //findType<tab>findProperties<tab>changeProperties<tab>findChangeOptions<tab>description
    //Where:
    //<tab> is a tab character
    //findType is "text", "grep", or "glyph" (this sets the type of find/change operation to use).
    //findProperties is a properties record (as text) of the find preferences.
    //changeProperties is a properties record (as text) of the change preferences.
    //findChangeOptions is a properties record (as text) of the find/change options.
    //description is a description of the find/change operation
    //Very simple example:
    //text          {findWhat:"--"}          {changeTo:"^_"}          {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}          Find all double dashes and replace with an em dash.
    //More complex example:
    //text          {findWhat:"^9^9.^9^9"}          {appliedCharacterStyle:"price"}          {include footnotes:true, include master pages:true, include hidden layers:true, whole word:false}          Find $10.00 to $99.99 and apply the character style "price".
    //All InDesign search metacharacters are allowed in the "findWhat" and "changeTo" properties for findTextPreferences and changeTextPreferences.
    //If you enter backslashes in the findWhat property of the findGrepPreferences object, they must be "escaped"
    //as shown in the example below:
    //{findWhat:"\\s+"}
    //For more on InDesign scripting, go to http://www.adobe.com/products/indesign/scripting/index.html
    //or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
    main();
    function main(){
              var myObject;
              //Make certain that user interaction (display of dialogs, etc.) is turned on.
              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
              if(app.documents.length > 0){
                        if(app.selection.length > 0){
                                  switch(app.selection[0].constructor.name){
                                            case "InsertionPoint":
                                            case "Character":
                                            case "Word":
                                            case "TextStyleRange":
                                            case "Line":
                                            case "Paragraph":
                                            case "TextColumn":
                                            case "Text":
                                            case "Cell":
                                            case "Column":
                                            case "Row":
                                            case "Table":
                                                      myDisplayDialog();
                                                      break;
                                            default:
                                                      //Something was selected, but it wasn't a text object, so search the document.
                                                      myFindChangeByList(app.documents.item(0));
                        else{
                                  //Nothing was selected, so simply search the document.
                                  myFindChangeByList(app.documents.item(0));
              else{
                        alert("No documents are open. Please open a document and try again.");
    function myDisplayDialog(){
              var myObject;
              var myDialog = app.dialogs.add({name:"FindChangeByList"});
              with(myDialog.dialogColumns.add()){
                        with(dialogRows.add()){
                                  with(dialogColumns.add()){
                                            staticTexts.add({staticLabel:"Search Range:"});
                                  var myRangeButtons = radiobuttonGroups.add();
                                  with(myRangeButtons){
                                            radiobuttonControls.add({staticLabel:"Document", checkedState:true});
                                            radiobuttonControls.add({staticLabel:"Selected Story"});
                                            if(app.selection[0].contents != ""){
                                                      radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
              var myResult = myDialog.show();
              if(myResult == true){
                        switch(myRangeButtons.selectedButton){
                                  case 0:
                                            myObject = app.documents.item(0);
                                            break;
                                  case 1:
                                            myObject = app.selection[0].parentStory;
                                            break;
                                  case 2:
                                            myObject = app.selection[0];
                                            break;
                        myDialog.destroy();
                        myFindChangeByList(myObject);
              else{
                        myDialog.destroy();
    function myFindChangeByList(myObject){
              var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
              var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
              var myStartCharacter, myEndCharacter;
              var myFindChangeFile = myFindFile("/FindChangeSupport/FindChangeList.txt")
              if(myFindChangeFile != null){
                        myFindChangeFile = File(myFindChangeFile);
                        var myResult = myFindChangeFile.open("r", undefined, undefined);
                        if(myResult == true){
                                  //Loop through the find/change operations.
                                  do{
                                            myLine = myFindChangeFile.readln();
                                            //Ignore comment lines and blank lines.
                                            if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")|| (myLine.substring(0,5)=="glyph")){
                                                      myFindChangeArray = myLine.split("\t");
                                                      //The first field in the line is the findType string.
                                                      myFindType = myFindChangeArray[0];
                                                      //The second field in the line is the FindPreferences string.
                                                      myFindPreferences = myFindChangeArray[1];
                                                      //The second field in the line is the ChangePreferences string.
                                                      myChangePreferences = myFindChangeArray[2];
                                                      //The fourth field is the range--used only by text find/change.
                                                      myFindChangeOptions = myFindChangeArray[3];
                                                      switch(myFindType){
                                                                case "text":
                                                                          myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                                                case "grep":
                                                                          myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                                                case "glyph":
                                                                          myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                                                          break;
                                  } while(myFindChangeFile.eof == false);
                                  myFindChangeFile.close();
    function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change preferences before each search.
              app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences = NothingEnum.nothing;
              var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              myFoundItems = myObject.changeText();
              //Reset the find/change preferences after each search.
              app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences = NothingEnum.nothing;
    function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change grep preferences before each search.
              app.changeGrepPreferences = NothingEnum.nothing;
              app.findGrepPreferences = NothingEnum.nothing;
              var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              var myFoundItems = myObject.changeGrep();
              //Reset the find/change grep preferences after each search.
              app.changeGrepPreferences = NothingEnum.nothing;
              app.findGrepPreferences = NothingEnum.nothing;
    function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){
              //Reset the find/change glyph preferences before each search.
              app.changeGlyphPreferences = NothingEnum.nothing;
              app.findGlyphPreferences = NothingEnum.nothing;
              var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";
              myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";
              myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";
              app.doScript(myString, ScriptLanguage.javascript);
              var myFoundItems = myObject.changeGlyph();
              //Reset the find/change glyph preferences after each search.
              app.changeGlyphPreferences = NothingEnum.nothing;
              app.findGlyphPreferences = NothingEnum.nothing;
    function myFindFile(myFilePath){
              var myScriptFile = myGetScriptPath();
              var myScriptFile = File(myScriptFile);
              var myScriptFolder = myScriptFile.path;
              myFilePath = myScriptFolder + myFilePath;
              if(File(myFilePath).exists == false){
                        //Display a dialog.
                        myFilePath = File.openDialog("Choose the file containing your find/change list");
              return myFilePath;
    function myGetScriptPath(){
              try{
                        myFile = app.activeScript;
              catch(myError){
                        myFile = myError.fileName;
              return myFile;
    This is a very useful and easy to maintain script which even people who cant write scripts (but know how to use regex) can do complex search replace mass replacements.
    Would love to find something like this for FrameMaker 12 (as i can't write scripts myself).
    regards
    daniel

    I have visited that site. The first item in the external link says: "You can also configure Firefox to automatically search for text when you type any characters outside of a text field. When typing in a text field these characters should show up in the text field and not trigger the Quick Find bar. "
    What I am looking for is the exact opposite. Once my first search is entered in the text box, and the info comes back, I want to start typing the next symbol, and have it automatically show up in the text box, not the Quick Find box. That is how it was working up until a couple of months ago.

  • Find/Replace Extended Character Set characters in filenames in one pipeline

    Hello all,
    I have to work with some very bored people. Instead of putting a dash (hex 2d) into a filename, they opt for something from this
    set of extended characters, which makes my regular expressions fail.  IS there a way I can efficiently find & replace anything outside the standard character set
    in one pipelinewithout finding and replacing a character at a time?
    So,I'd like something like:
    get-childitem * | where-object $_.name -match '\x99' | rename-item -newname { $_.name -replace '\x99','='}
    from hex 80 to hex FF rather than a for-each.
    Thanks.

    Answer would depend on the way you want to replace... Easier if you want replace any char in set with selected char:
    $Name = -join (180..190|%{[char]$_})
    New-Item -ItemType File -Name $Name
    Get-ChildItem * | Rename-Item -NewName {
    [regex]::Replace(
    $_.Name,
    '[\xB4-\xBE]',
    } -WhatIf
    But if you want it more complicated, you may do that too. E.g. defining hashtable that can be used to replace individual elements:
    $Replacer = @{}
    foreach ($Char in (180..190 | % { [char]$_ })) {
    $Replacer.Add(
    [string]$Char,
    (echo _, -, =, . | Get-Random)
    $Replacer
    Get-ChildItem * | Rename-Item -NewName {
    [regex]::Replace(
    $_.Name,
    '[\xB4-\xBE]',
    $Replacer[$args[0].Value]
    } -WhatIf
    Using this syntax make it possible to include some logic in replace. E.g. you could easily use switch to decide what to do with given string:
    Get-ChildItem * | Rename-Item -NewName {
    [regex]::Replace(
    $_.Name,
    '[\xB4-\xBE]',
    switch ($args[0].Value) {
    º { "0" }
    µ { "u" }
    ¹ { "1" }
    ¸ { "," }
    Default { "_" }
    } -WhatIf

  • Universally replace one character with another and then change font

    Hello,
    I have a geologic map file where there are hundreds of labels like Cc, Cz, Cwu, etc... all in the Arial font. I need to change all of the capital C's with a character from the StratagemAge font. That is to say, I need to find all instances of one character in my file and then replace them with another character and then change the font of that selected character.
    I've been trying to figure out how to write an action to do this, but I was wondering if there is a way to do this easily already.
    Any suggestions?
    Jeremy

    > how do you turn off the dialog for the Find/Replace in action palette?
    At the left of each Action step is a square field. Mouse over it and the tooltip will read "Toggle Dialog On/Off".
    > I got an action that I wrote to work, but it takes a button click for each instance in my file that I want to change. Would yours have that same drawback as that?
    Yes, you would have to click each time to run the Action (or, you could assign a function key), but there would be no dialog to dismiss.
    But you can pile several iterations of the same steps in the Action; so that one execution of the Action does ten replacements with one click, for example.
    This would not be a particularly difficult thing to Javascript, but you are correct that scripting has a learning curve. This task is not something I would think often needed. Doing a few hundred replacements in a file, using an Action would not seem overly burdensome to me. But if it is a recurring need for you, it might be worth writing a script.
    JET

  • Trying to find replacement mouse/ trouble with existing mouse

    The mouse that came with my HP bundle has finally decided to crap out on me. I will click something like a box that can be checkmarked and with one click it will check it and uncheck it. Also when using the calculator I could hit one digit and it will enter that # twice. So I'm thinking my mouse has about had it.
    Not sure if much I can do to clean it. I'd like to stay away from compressed air. I tried using the vacuum to suck up some of the dust. But not sure how much that did, since I'm still having issues. Also tried sliding the sticky side of a post it note in the cracks to gather up some dust. Little results. 
    Onto the next thing on what replacement I found. 
    On the back I have found it be Model # N910U, but trying to search the HP site all I can find similar is this one, looks exactly like mine, but not finding it to be the same model #. 
    http://www.shopping.hp.com/en_US/home-office/-/products/Accessories/Mice-and-Keyboards/KY619AA?HP-US...
    Is this the same item or what? 

    mws1984,
    Your mouse is a corded optical mouse, any such mouse mouse will work, including the one you linked.
    PS> the shipping on that mouse is $10. It's such a trivial item, your local stores will have many selections.
    I am a volunteer. I am not an HP employee.
    To say THANK YOU, press the "thumbs up symbol" to render a KUDO. Please click Accept as Solution, if your problem is solved. You can render both Solution and KUDO.
    The Law of Effect states that positive reinforcement increases the probability of a behavior being repeated. (B.F.Skinner). You toss me KUDO and/or Solution, and I perform better.
    (2) HP DV7t i7 3160QM 2.3Ghz 8GB
    HP m9200t E8400,Win7 Pro 32 bit. 4GB RAM, ASUS 550Ti 2GB, Rosewill 630W. 1T HD SATA 3Gb/s
    Custom Asus P8P67, I7-2600k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX660 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Custom Asus P8Z77, I7-3770k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX670 2GB, 750W OCZ, 1T HD SATA 6Gb/s
    Both Customs use Rosewill Blackhawk case.
    Printer -- HP OfficeJet Pro 8600 Plus

  • Replace specif character with other chracter before or after ','

    a:='(a,c,dklcm,c,npc,c)'
    (a,c,dklcm,c,npc,c) these is a string value i can't change within these
    how will i replace specific chracter like c with other character
    keeping in mind that 'c' will between ',' and ',' and
    at the end before ')'.If c is not present at the end then it will be
    kept intact.

    SQL> select '(''a'',null,''dklnullm'',null,''npnull'',null)' ORIGINAL_VALUE from dual;
    ORIGINAL_VALUE
    ('a',null,'dklnullm',null,'npnull',null)
    SQL> SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE('(''a'',null,''dklnullm'',null,''npnull'',null)',',null,','~'),'null)','^'),'null',''''''),'~',',null,'),'^','null)') REPLACED_VALUE FROM DUAL;
    REPLACED_VALUE
    ('a',null,'dkl''m',null,'np''',null)

  • Replace A Character With Another Character

    Can anyone help me with code to replace "." with a "-", within a string of numbers?
    ie. Change "401.001" to "401-001"
    I am using Adobe Acrobat 6.0 Professional
    Thanks

    Is the text in the body of the document or inside form fields?

  • Finder: replace a file with another file

    Let's say I want a game to play my favorite song when the game is supposed to be playing its own theme song.  The theme song is in a sound file that is located on my computer's hard drive.  The theme song sound file is in the same format as the sound file that contains my favorite song, so I don't need to convert any files.  What is the easiest way to make the game think that the sound file I want the game to use is the sound file of the theme song?

    You could hack the software and change the code to use some other file, but that will not be easier.
    Either change the code or change the target. Unless the game provides a preference to change the sound, there isn’t another option.

  • How to find a Sales document with Certain type and having a certain Matnr ?

    How can I find a sales document with a certain type and having a certain materail.
    is there any table to find that ??
    Thanks
    Venkat

    Hi Venkat,
    I found this table interesting. Pls. check with the table VBAP_VAPMA, it has the data of the header along with the items.
    Reward if it helps.
    Regards,
    Sreekanth

  • Find & Replace

    I'm trying to get DW 8 to allow me to remove some of the
    "found" items before using the replace function to avoid having to
    open each file individually - but when I delete entries from the
    "found" list, on r-click I'm given 3 options:
    - Open File
    - Find & Replace
    - Clear Results
    The Find & Replace option takes me back to the original
    Find & Replace screen. With DW4 you have the option of deleting
    some of the "found" entries before pressing the "replace" button.
    Has DW really taken a backward step?

    I neevr used DW4, so I'm not certain how that worked. And it
    doesn't look like you can delete entries from the Search panel.
    You might use other techniques to limit your changes. Any
    folders or files that are cloaked will not be updated by the
    Replace. You can set cloaking for specific files or folders, or by
    file extension (on the Site panel). Or, you could select only the
    files you want to target and use the Selected Files in Site option
    of the Find In drop-down. Or, you could use the Replace button in
    the Find/Replace panel to go through the results one at a time,
    rather than using Replace All.
    If you are changing HTML tags or attributes, the Find/Replace
    options are very powerful.

  • Replace a character in a String array

    I have an array of strings and am trying to replace the ' character with a space. I keep getting either a cannot be applied or cannot resolve symbol error. Can anyone help?
    String arrayList = request.getParameter("field");
    String newList = arrayList.replace("\'", " ");

    the replace method of the String class takes two parameters and both of them are characters not strings use it like this
    arrayList.replace('\'', ' ');that should fix it

  • Replacing a character in a String

    Hi All,
    How can I replace a character ' which appears in a String into \'

    There is a method in String that replaces all
    occurrences of one character with anothercharacter.
    It's called, hold your breath now, "replace".But tho OP wants to replace one character with two
    characters :)You're right, I missed that. Well, serves me right for being sarcastic. :-)

  • Replacing a char with string in a string buffer.

    Hi all,
    I have a huge xml file. Need to search for the following characters: ^ & | \ and replace each character with \T\ \F\ \B\ \C\ respectively.
    i.e. ^ must be replaced with \T\
    & must be replaced with \F\
    I see that it can be done in case of String using replaceAll() but have no clue about achieving using the stringbuffer??
    Any help is higly appeciated.
    Thanks in advance.

    Hi all,
    I have a huge xml file. Need to search for the
    following characters: ^ & | \ and replace each
    character with \T\ \F\ \B\ \C\ respectively.
    i.e. ^ must be replaced with \T\
    & must be replaced with \F\
    I see that it can be done in case of String using
    replaceAll() but have no clue about achieving using
    the stringbuffer??
    Any help is higly appeciated.
    Thanks in advance.here the solution for your problem:
    example code as follows,
         StringBuffer stringBuffer = new StringBuffer("your xml content");           
                String xmlString = stringBuffer.toString();
                char[]  xmlCharArray =  new char[];
                xmlString.getChars(0, xmlString.length()-1, xmlCharArray, 0);
               StringBuffer alteredXmlBuf = new StringBuffer();
                for(int i=0; i<xmlCharArray.length; i++){
                               if( xmlCharArray[i] == '^'){
                                      alteredXmlBuf.append(" \\T\\") ;
                               }else if(xmlCharArray[i] == '&'){
                                      alteredXmlBuf.append(" \\F\\") ;
                               }else if(xmlCharArray[i] == '|'){
                                      alteredXmlBuf.append(" \\B\\") ;
                               }else if(xmlCharArray[i] == '\'){
                                      alteredXmlBuf.append(" \\C\\") ;
                               }else {
                                       alteredXmlBuf.append(xmlCharArray);
    now alteredXmlBuf StringBuffer object contains your solution.

  • Replace a character

    Hi all
    I have a ascii file should I replace a character with another. How can I do with form?
    regards
    Silvia

    Open the file with a text editor would be the simplest solution:
    client_host('cmd /c start myfile.txt');
    The start command will cause the default application that is associated with the txt extension to open the file.

Maybe you are looking for

  • Why do I get a program error when trying to save a file

    I've loaded and reinstalled photoshop elements 3 times. I can not save any files. all i get is cannot save file do to  program error message' this is a brand new product with a program error and they want me to pay them to fix there problem. it ain't

  • Multiple Users on one Itune

    So my roommate just bought an ipod video.So MY whole library is on there(iTunes),since she used it...somehow my library shows 2589 songs,and when I plug my ipod in (click on the name) all I see is 2366 songs. What am I doing wrong? Why am I suddenly

  • Kernel panic when i open logic

    Hello people i need your help! This is driving me crazy. Has anyone had this before? Does anyone know what to do? When i open logic i get a kernel panic as the 'updating tree' dialouge gets halfway. I have now idea what, how and why its doing it. it

  • I installed a 2nd hard drive and now my mac wants to startup on that drive. How do I switch startup drives?

    I installed a second hard drive to my Mac Mini. After installing the operation system on it the mac will boot up on the second hard drive. How do switch back to the first drive? Thank you.

  • Accessing music files on external hard drives with Home Sharing

    I use my iMac as a computer and music server.  I have it connected via USB and SPDIF to my audio system, and access my music files with the Remote app on my iPhone.  It works fine except when the Remote app occasionally wants to take a brief break.