Solved

DelphiXE2: How to load pure plain text from local MHT file FAST?

Posted on 2013-06-04
9
360 Views
Last Modified: 2013-09-12
How can pure plain text (without tags and formatting stuff) be loaded from a local MHT file FAST? (MHT file saved from MS Internet Explorer).
0
Comment
Question by:PeterDelphin
  • 4
  • 3
9 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39219660
MHT's are text files that are formatted like HTML Multi-Part emails are.  They use MIME boundaries to separate the sections and images are encoded in base64 like they would be in emails.  Here is the first few lines from an MHT I made from a phpinfo page.  If you just want the content between the tags in the HTML body, you'll have to have something 'parse' it out.

From: "Saved by Windows Internet Explorer 8"
Subject: phpinfo()
Date: Mon, 14 Mar 2011 15:44:56 -0400
MIME-Version: 1.0
Content-Type: multipart/related;
	type="text/html";
	boundary="----=_NextPart_000_0000_01CBE25E.C4F42950"
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18263

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01CBE25E.C4F42950
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://bbpweb:811/getinfo.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" =
"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML><HEAD><TITLE>phpinfo()</TITLE>
<META content=3D"text/html; charset=3Dwindows-1252" =
http-equiv=3DContent-Type>
<STYLE type=3Dtext/css>BODY {
	BACKGROUND-COLOR: #ffffff; COLOR: #000000
}

Open in new window

0
 

Author Comment

by:PeterDelphin
ID: 39221664
DaveBaldwin, if I knew the MHT parsing format (which I think is rather complex) I would have already written a parsing function for this purpose.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39223121
It is not that complex, it looks just like the source for an email that uses the MIME boundaries to separate the parts.  You can open an *.mht file in Notepad or any other text editor and see everything.

http://www.sitepoint.com/forums/showthread.php?613263-What-is-mht-format

http://en.wikipedia.org/wiki/MIME#Multipart_messages
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:PeterDelphin
ID: 39224055
I have looked at the source code of a lot of different MHT files. They don't have enough similar structural information to make it possible to parse them.

If you are so sure about how easy it is to parse MHT files, please show me how to do it.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39224142
0
 

Author Comment

by:PeterDelphin
ID: 39233468
I am still evaluating the Chilkat components.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39233491
Take your time, I'm in no hurry.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question