RE: Inserting XML code into HTML source

Subject: RE: Inserting XML code into HTML source
From: "Inbar, Paul" <paul -dot- inbar -at- intel -dot- com>
To: "Moshe Kruger \(AllWrite\)" <moshe -dot- kruger -at- gmail -dot- com>
Date: Wed, 22 Aug 2007 11:48:59 +0300

Hi Moshe and Bill,

I think that the pre tag is more for handling the whitespace (indentation, spaces etc.) in the sample, and doesn't necessarily prevent something enclosed in angle brackets from being interpreted as part of the html of the page. For example, in the following example, in my browser (I.E. 6 on Windows XP) the <1> gets displayed fine, while the text that starts with <book> and ends with </book> (i.e. a bit of "xml") is simply not displayed in the browser

<html>
<body>

Here are some code samples:

<p>The following is visible</p>

<pre>
<1>
</pre>

<p>The following is invisible</p>

<pre>
<book>
<author>
</author>
</book>
</pre>

</body>
</html>

To avoid the uncertanties of using the pre tags alone, I maintain my code samples in a separate file, and then convert all the special characters (e.g. < to &lt;, etc.) with a Perl script before copying them into my html documents.

I have looked for a way that would avoid the "dirty" html that results but have not found one. When you think of it, though, who cares? If you want someone to be able to cut and paste the sample, they can do it from the browser window, and not from the source. And if you feel that your html source isn't "readable", do as I did and keep the samples in the original code in separate files, where you can check them, run them, whatever, and only convert at the last minute. If you are worried about having to do a lot of cutting and pasting, then instead of maintaining only a final version of your html page, maintain a working copy, where the samples are represented by uniq placeholders, and then, when you are going to publish, use a script to generate the published copy, where the script will replace the placeholders with the samples which are pulled from the separate code sample files.

This is the approach that has worked for me. I would be interested though in hearing about other approaches that have worked.

In any event, good luck,

Paul



-----Original Message-----
From: techwr-l-bounces+paul -dot- inbar=intel -dot- com -at- lists -dot- techwr-l -dot- com [mailto:techwr-l-bounces+paul -dot- inbar=intel -dot- com -at- lists -dot- techwr-l -dot- com] On Behalf Of Bill Swallow
Sent: Tuesday, August 21, 2007 4:11 PM
To: Moshe Kruger (AllWrite)
Cc: Techshoret; techwr-l -at- lists -dot- techwr-l -dot- com
Subject: Re: Inserting XML code into HTML source

Wrap the code in <pre> ... </pre> tags.

On 8/21/07, Moshe Kruger (AllWrite) <moshe -dot- kruger -at- gmail -dot- com> wrote:
> Hello all,
>
> I am creating HTML pages with code samples in them.
>
> Problem: How do I insert XML code into HTML without resorting to special
> HTML characters (eg: &lt; and &gt;)?
>
> I am using Dreamweaver. I have found I can put the code into the Design
> window, of course, and then get the awful HTML code that results.
>
> Anyone have a "cleaner" trick?

--
Bill Swallow
HATT List Owner
WWP-Users List Owner
Senior Member STC, TechValley Chapter
STC Single-Sourcing SIG Manager
http://techcommdood.blogspot.com
avid homebrewer and proud beer snob
"I see your OOO message and raise you a clue."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Create HTML or Microsoft Word content and convert to Help file formats or
printed documentation. Features include support for Windows Vista & 2007
Microsoft Office, team authoring, plus more.
http://www.DocToHelp.com/TechwrlList

True single source, conditional content, PDF export, modular help.
Help & Manual is the most powerful authoring tool for technical
documentation. Boost your productivity! http://www.helpandmanual.com

---
You are currently subscribed to TECHWR-L as paul -dot- inbar -at- intel -dot- com -dot-

To unsubscribe send a blank email to
techwr-l-unsubscribe -at- lists -dot- techwr-l -dot- com
or visit http://lists.techwr-l.com/mailman/options/techwr-l/paul.inbar%40intel.com


To subscribe, send a blank email to techwr-l-join -at- lists -dot- techwr-l -dot- com

Send administrative questions to admin -at- techwr-l -dot- com -dot- Visit
http://www.techwr-l.com/ for more resources and info.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Create HTML or Microsoft Word content and convert to Help file formats or
printed documentation. Features include support for Windows Vista & 2007
Microsoft Office, team authoring, plus more.
http://www.DocToHelp.com/TechwrlList

True single source, conditional content, PDF export, modular help.
Help & Manual is the most powerful authoring tool for technical
documentation. Boost your productivity! http://www.helpandmanual.com

---
You are currently subscribed to TECHWR-L as archive -at- web -dot- techwr-l -dot- com -dot-

To unsubscribe send a blank email to
techwr-l-unsubscribe -at- lists -dot- techwr-l -dot- com
or visit http://lists.techwr-l.com/mailman/options/techwr-l/archive%40web.techwr-l.com


To subscribe, send a blank email to techwr-l-join -at- lists -dot- techwr-l -dot- com

Send administrative questions to admin -at- techwr-l -dot- com -dot- Visit
http://www.techwr-l.com/ for more resources and info.


References:
Re: Inserting XML code into HTML source: From: Bill Swallow

Previous by Author: RE: Working with large documents in Word
Next by Author: RE: Inserting XML code into HTML source
Previous by Thread: Re: Inserting XML code into HTML source
Next by Thread: RE: Inserting XML code into HTML source


What this post helpful? Share it with friends and colleagues:


Sponsored Ads