Find a specific line in text followed by another specific line...

I am trying to search through an xml document find the

tag followed on the next line by

and replace the two lines with just

I’ve have tried every combination of return, but it doesn’t recognize it. I either just changes the

tag, or nothing at all.

Here is a snippet of my applescript, followed by a snippet of my xml.

	try
		set ff to open for access theFile with write permission
		set theText to (read ff)
		
		set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "<p>" & return & "<p align=\"center\"><b>"}
		set theText to text items of theText
		set AppleScript's text item delimiters to "<p align=\"center\"><b>"
		set theText to theText as string
		set AppleScript's text item delimiters to ASTID
		write theText to ff starting at 0
		close access ff
	end try

XML

TRAINING FOR CNA
Day 3 week & Evening 6 week Weekend Classes.
Early bird discount.
www.newaydirections.com or
Call Neway Directions
608-221-1920

Thanks in advance for any help.

Here you go.

set p to open for access file theFile with write permission
set theCont to read p
set toWrite to doIT(theCont)
set eof p to 0
write toWrite to p
close access p

on doIT(theCont)
	set text item delimiters to "<p>
<p align=\"center\"><b>"
	set item2 to item 2 of (text items of theCont)
	set item2 to "<p align=\"center\"><b>" & item2
	set text item delimiters to ""
	return item2
end doIT

A common problem is that files are line terminated differently so your file is probably not cr terminated but lf or crlf. Change return to string id {13, 10} or string id {10} and probably one of the two will work. You could also use ‘file’ command to determine the line terminators of a text file btw.