1

XMLは、XSLを使用してブラウザーで変換できます。これは、xmlファイル内に次の行を追加してxml内のxslを参照することによって実行できます。

<?xml-stylesheet type='text/xsl' href='sample.xsl'?>

Internet Explorerでこのxmlファイルを開くと、ブラウザに正しいデータが表示されます。

XML自体は、他の多くのファイルを、たとえば、あるフォルダーにある画像として参照します。

表示されたデータ(参照されているすべてのデータを含む)を1つのmhtmlファイル(* .mht)に保存したい

どうすれば続行できますか?そして、これは可能ですか?

注:ファイルはすべてローカル(サーバー上ではない)であり、初期xmlはテストデータの結果です。mhtmlファイル以外の他のデータにアクセスせずに、単一のファイルから開始する前と同じようにXMLファイルを正しく表示したいだけです。

回答1で編集:

HTMLのiFrame内にxmlを含めました:

<body><iframe src="name.xml" width = "100%" height="1000"> </iframe></body>

これは、IEを使用して*.mhtファイルに保存しました。

From: <Saved by Windows Internet Explorer 7>
Subject: XML-Test
Date: Wed, 22 Feb 2012 14:47:34 +0100
MIME-Version: 1.0
Content-Type: multipart/related;
    boundary="----=_NextPart_000_0000_01CCF170.E99B1DF0"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01CCF170.E99B1DF0
Content-Type: text/html;
    charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: file://C:\Documents and Settings\STEFFAN\Desktop\Test\XML-Test.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>XML-Test</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.6000.17107" name=3DGENERATOR></HEAD>
<BODY><IFRAME=20
src=3D"http://www.m.de/name.xml"=20
width=3D"100%" height=3D1000>
</IFRAME></BODY></HTML>

------=_NextPart_000_0000_01CCF170.E99B1DF0
Content-Type: text/xml;
    charset="unicode"
Content-Transfer-Encoding: base64
Content-Location: http://www.m.de/name.xml

//48ACEARABPAEMAVABZAFAARQAgAEgAVABNAEwAIABQAFUAQgBMAEkAQwAgACIALQAvAC8AVwAz
AEMALwAvAEQAVABEACAASABUAE0ATAAgADQALgAwACAAVAByAGEAbgBzAGkAdABpAG8AbgBhAGwA...

もともと「http://www.m.de/name.xml」の代わりにローカルファイルを使用しているので、「file:// C:\ Documents andSettings \ STEFFAN \ Desktop \ Test\SUPL_TCLog.xml」がIEから出力されました。

しかし、このローカル参照はmhtmlでは機能しないようです。そのため、ランダムな代替(http://www.m.de/name.xml)を使用しました。(これは画像ファイルに対しては正常に機能します)。それに応じて変更すると、mhtファイルが開き、xmlファイルのダウンロードが開始されます。しかし、これは望まれていません。表示してほしい。

何が欠けている?

4

2 に答える 2

0

This is possible, but you will have to build some things yourself.

MHTML is essentially a multipart email message. Its format is fully described by RFC-2557. It can be generated by email message generators and serializers.

However I am unaware of any tool that will generate MHTML programmatically. Be warned, too, that there is no one standard web archive format (there are at least four), and only IE, Opera, and Chrome can read MHTML.

The simplest thing that can work is to script IE to open your page and save it as MHTML.

If you want to generate MHTML without IE, then you need to create an MHTML archiver.

With an archiver, the simplest thing to do is to:

  1. include all possible external resources
  2. make sure all those resources are always referenced by the same url
  3. then use a matching content-location for that resource.

This way you do not need to rewrite href and src attributes or parse your xsl or html to discover what resources to include.

If there are too many possible external resources or you can't use paths consistently, you will need to do parsing for resource discovery and/or url rewriting.

In any scenario you can either save the xml+xsl, or you can generate the HTML output first and save that.

于 2012-02-22T15:09:49.220 に答える
-1

いくつかの試みを試みましたが、成功しませんでした。Francis Avila の提案も解決できませんでした。

特に、javascript によって参照されるコードには、他の参照も含まれていました。これらを解決してmhtmlに入れる方法がわかりませんでした。

Altova StyleVision を使用することが解決策になるかもしれません。

私はもう試していないので。このスレッドを閉じます。

于 2012-10-22T11:59:58.127 に答える