Copy link to clipboard
Copied
Hi Everyone,
I have a Textframe with value ($00.00) between two xml tags. one tag for "$" and another one for value(00.00).
Now I need find those value (00.00) and replace value(24.10). If I run the script, Its remove the price XML tag and updated the price.
My expectation is update theose value without removing the XML tag.
Please suggest me where I did the mistake in the code. Kindly find the screen shot and code for your reference.
Before run the Script: After Run the Script:
Code:
var flgGREP="[$]\\d+[.]\\d+"
var Price="$24.10"
myLine=app.selection[0];
FindReplaceValue(flgGREP,Price,myLine);
function FindReplaceValue(findValue,replaceValue,Sapps){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = findValue;
app.changeGrepPreferences.changeTo = replaceValue;
Sapps.changeGrep();
}
-yajiv
That's because the XML tag (both opening and closing representations) is a special character but a generic one.
So the grep pattern above would fail because you have text like [TAG]$[TAG][TAG]00.00[TAG] will not be picked up by the grep engine.
However there is no (unless I am wrong) a metacharacter that would spot the tags marks. You can do it in text F/R but of course it's not as smooth than grep.
Bad news is that those special characters won't be saved if you do F/R on a tagged content (I mean i
...Copy link to clipboard
Copied
var flgGREP="(? <=$)\\d+\\.\\d+"
Copy link to clipboard
Copied
Hi Skemicle,
Thank you for your prompt response.
The value is not updated to the text Frame.
-yajiv
Copy link to clipboard
Copied
That's because the XML tag (both opening and closing representations) is a special character but a generic one.
So the grep pattern above would fail because you have text like [TAG]$[TAG][TAG]00.00[TAG] will not be picked up by the grep engine.
However there is no (unless I am wrong) a metacharacter that would spot the tags marks. You can do it in text F/R but of course it's not as smooth than grep.
Bad news is that those special characters won't be saved if you do F/R on a tagged content (I mean in the very case above).
Good luck for you is that you seem to knw the markupTag which host the price = copy_frame so I would do domething like :
var root = app.activeDocument.xmlElements[0];
var copy_frame_tags = root.evaluateXPathExpression (".//copy_frame" );
var tag;
while ( tag = copy_frame_tags.pop() ) {
tag.contents=="00.00" && tag.contents="24.10";
}
HTH
Loic
Copy link to clipboard
Copied
Thank you Loic,
Its working like charm...
As well as I got Idea on evaluateXPathExpression works.
-yajiv