Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Step 2 - Manipulation

July 10, 2000

Okay, now that the file is uploaded and you have the filename, now's the time to do some manipulation of the file. We'll use the file system object here to do the grunt work.

If you converted the document from a word processor's format to HTML, chances are you'll have a bunch of extraneous HTML tags that you don't want in there. For instance, Microsoft Word adds in a bunch of XML and CSS tags that are used to convert the HTML document back into a Word document, should you ever choose to do so. However, those extra tags add a lot of overhead to the HTML document, so if you're never planning on converting the document back to the Word format, you should get rid of those extra tags. This can be done with a bunch of replaces.

Const fsoForReading = 1 
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")     <-- create the filesystem object
Set objTextStream = objFSO.OpenTextFile("C:\SomeFile.html", fsoForReading)      <-- open the uploaded file
txtFileContents = objTextStream.ReadAll
objTextStream.Close     <-- close the file


If instr(1, txtFileContents, "<xml>", vbTextCompare) then  <-- if <xml> is found in the text, remove it
	txtFileContents = Replace(txtFileContents, "<xml>", "", 1, -1, vbTextCompare)
End If
.  <-- remove any other tags that we don't want
.	
.


Now write the changes we just made
Const fsoForWriting = 2 
Set objTextStream = objFSO.OpenTextFile("C:\SomeFile.html", fsoForWriting)      <-- open the uploaded file
objTextStream.Write(txtFileContents)
objTextStream.Close     <-- close the file


set objFSO = Nothing

Note that it may take a lot of these loops and fine tuning to get rid of all the junk HTML in the files. Though this step is fairly easy, it takes a while to get it right. You can also perform any other file manipulation here, for instance, if you need to change the filename, do a global replace, add in a style sheet, etc.

NOTE: If you use the file system object (FSO) to change the filename, make sure that you also update the filename field in the database. Otherwise you'll have a database entry that points no where, and a file that doesn't belong to anything.

The Back End
Content Management Made Easy with ASP
Step 2 (cont.) - Multiple pages


Up to => Home / Authoring / ASP / Content_Management




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers