PDA

View Full Version : String.Replace in a .htm file



Jim Smiley
10-28-2005, 11:15 AM
Hi all;

I'm trying to update a .htm file with info the user provides. Found this code in the Forum and it works well.


-- Load in your html file
SourceFile = TextFile.ReadToString("AutoPlay\\Docs\\FMP.htm")

-- get the data from our input fields
text1 = Input.GetText("Input1");

-- Find and replace the text
result = String.Replace(SourceFile, "Pers_Chrg", text1, true);

-- Save the file
TextFile.WriteFromString("AutoPlay\\Docs\\FMP2.htm", result, false)


Problem is I need to replace several sections of the SourceFile (Pers_Chrg, Address1, Address2, City, State, Zip, Phone, etc.)

Am I going about this the "right" way? How would one go about getting all the info into the file?

Regards

Jim Smiley

TJ_Tigger
10-28-2005, 01:04 PM
Yes you are going about it correctly.

Read the html file to a string.
Make your replace actions on the string
Write the string out to a file.

Tigg

Desmond
10-28-2005, 03:05 PM
Hello,

Attached is an example i cooked up. May not be the world's best (if you have a LOT of values, a table at the beginning and a loop would probably be better -- easier updates), but it works!!

Jim Smiley
10-28-2005, 03:22 PM
Desmond;

Thanks. I was having trouble with the order in which to place the data. Your example tells me what I was missing.

I do have quite a bit of data so look forward to "Table" questions in the near future.

Regards;

Jim Smiley