Copy link to clipboard
Copied
Hi,
My requirement is to remove XML text markers between xml tags. It is like symbol :: :: .
It is already discussed in forum, link below:
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
Copy link to clipboard
Copied
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){}
}
}
Copy link to clipboard
Copied
Thanks Karthik. Sorry it is not working. Nothing removed.
Copy link to clipboard
Copied
Its working for me. copy the script in to script path and run.
Copy link to clipboard
Copied
Really? Tried with script path, not working
Tried in CS6 and CC2014
Copy link to clipboard
Copied
Marks are like below:
Copy link to clipboard
Copied
Sorry for my misunderstanding
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi Karthi,
did you try TEXT Search/Replace with <FEFF> ?
Not GREP Search/Replace…
Regards,
Uwe
Copy link to clipboard
Copied
Hi Uwe,
Yes i tried in TEXT search method... It find but can't able to delete.
Regards,
Karthi
Copy link to clipboard
Copied
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 😉
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Karthi, please provide a testfile, with a exact description, what should be removed and what must stay in the doc. Thanks.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 !!
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
Copy link to clipboard
Copied
I still do not get why you want to remove something.
Copy link to clipboard
Copied
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 = stories.findGrep(true);
for (j=0; j<myFind.length; j++){
app.changeGrepPreferences.changeTo ="";
flgsel.changeGrep();
}
}
I suspect it is because of that hidden marks.
Thanks,
Karthi
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Hi Uwe,
Hope that trick will work. Yes when i am selecting content it contains XML markers in between
Thanks,
Karthi
Copy link to clipboard
Copied
Hi tpk1982, hope you've already solve your problem. I've found that ~| is the GREP version of the XML text anchor, so the GREP string [^~|]+ will find all the characters that aren't an XML text anchor. Including the GREP search into a script will allow you to select only the real characters. We are having the same problems trying to update a document with data from a CSV.
Copy link to clipboard
Copied
Thanks Claudio..
Copy link to clipboard
Copied
Did you find other solutions?
Copy link to clipboard
Copied
Not yet