473,735 Members | 3,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make html ignore code that is part of text?

I need to include code snippets in my html document, something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<appSettings>
<add key="Connection String" "Password=passw ord;Persist Security
Info=True;User ID=newuser;Init ial Catalog=catalog ;Data Source=localhos t" />
</appSettings>
</configuration>

If I try to put this in a regular document, I get errors... I've tried
enclosing it in <pre> tags, but that didn't help. How do I get this code
sample into a document?

Thanks
Jul 23 '05 #1
18 49064
deko wrote:
I need to include code snippets in my html document, something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<appSettings>
<add key="Connection String" "Password=passw ord;Persist Security
Info=True;User ID=newuser;Init ial Catalog=catalog ;Data Source=localhos t" />
</appSettings>
</configuration>

If I try to put this in a regular document, I get errors... I've tried
enclosing it in <pre> tags, but that didn't help. How do I get this code
sample into a document?


Change the less-than signs ("<") to "&lt;", the ampersands ("&") to
"&amp;", and the greater-than signs (">") to "&gt;".
Jul 23 '05 #2
deko wrote:
I need to include code snippets in my html document


You need to use &lt; and &gt; instead of < and >.

See http://tranchant.plus.com/web/html-tutorial/characters

--
Mark.
http://tranchant.plus.com/
Jul 23 '05 #3
> Change the less-than signs ("<") to "&lt;", the ampersands ("&") to
"&amp;", and the greater-than signs (">") to "&gt;".


Thanks!!
Jul 23 '05 #4
> See http://tranchant.plus.com/web/html-tutorial/characters

very helpful link... thanks!
Jul 23 '05 #5
"deko" <ww************ *************** ****@nospam.com > wrote:
I need to include code snippets in my html document, something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration >
<appSettings>
<add key="Connection String" "Password=passw ord;Persist Security
Info=True;Us er ID=newuser;Init ial Catalog=catalog ;Data Source=localhos t" />
</appSettings>
</configuration>

If I try to put this in a regular document, I get errors... I've tried
enclosing it in <pre> tags, but that didn't help. How do I get this code
sample into a document?


Replace occurrences of < with &lt; , for consistency you might also
consider replacing > with &gt;

Then enclose it in:

<pre><code>
....
</code></pre>

markup.

--
Spartanicus
Jul 23 '05 #6
> Replace occurrences of < with &lt; , for consistency you might also
consider replacing > with &gt;

Then enclose it in:

<pre><code>
...
</code></pre>

markup.


That did the trick:

<pre>
<code>
&lt?xml version="1.0" encoding="utf-8" ?&gt;
&ltconfiguratio n&gt
&ltappSettings& gt
&ltadd key="Connection String" "Password=passw ord;Persist Security
Info=True;User ID=newuser;Init ial Catalog=databas e;Data Source=localhos t"
/&gt
&lt/appSettings&gt
&lt/configuration&g t
</code>
</pre>

looks great... thanks
Jul 23 '05 #7
"deko" <ww************ *************** ****@nospam.com > wrote:
Replace occurrences of < with &lt; , for consistency you might also
consider replacing > with &gt;

Then enclose it in:

<pre><code>
...
</code></pre>

markup.
That did the trick:


Consider that an illusion.
<pre>
<code>
&lt?xml version="1.0" encoding="utf-8" ?&gt;
&ltconfiguratio n&gt
&ltappSettings& gt
&ltadd key="Connection String" "Password=passw ord;Persist Security
Info=True;User ID=newuser;Init ial Catalog=databas e;Data
Source=localhos t" /&gt
&lt/appSettings&gt
&lt/configuration&g t
</code>
</pre>


You are not using the semicolon as instructed. Terminating entity
references with semicolon has always been good practice in HTML, and in
XHTML it is obligatory - an XHTML conformant browser is _required_ to
choke on your usage. Besides, e.g. &ltadd is invalid in good old HTML
too, and is to be treated as an undefined entity reference.

As a minor detail, it is a bit safer to write

<pre><code>&lt; ?xml version="1.0" ...
...
&lt;/configuration&g t;</code></pre>

i.e. to have no line breaks after <pre> and <code> tags or before </code>
or </pre> tags. The reason is that many browsers get the relevant parsing
rules wrong and may understand the situation so that there is an empty
line at the start of the <pre> element and at the end of it. You might
see this if you set a background color or a border for the <pre> element.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #8
In our last episode,
<dA************ ******@newssvr2 9.news.prodigy. com>,
the lovely and talented deko
broadcast on comp.infosystem s.www.authoring.html:
I need to include code snippets in my html document, something like this: <?xml version="1.0" encoding="utf-8" ?>
<configuration >
<appSettings>
<add key="Connection String" "Password=passw ord;Persist Security
Info=True;User ID=newuser;Init ial Catalog=catalog ;Data Source=localhos t" />
</appSettings>
</configuration> If I try to put this in a regular document, I get errors... I've tried
enclosing it in <pre> tags, but that didn't help. How do I get this code
sample into a document?


Change < to &lt; and > to &gt;


--
Lars Eighner -finger for geek code- ei*****@io.com http://www.io.com/~eighner/
If it wasn't for muscle spasms, I wouldn't get any exercise at all.
Jul 23 '05 #9
On Wed, 08 Sep 2004 01:10:24 -0600, Lāʻie Techie
<laie@win_remov e_get_nospam_so lutions.com> declared in
comp.infosystem s.www.authoring.html:
(<pre> to preserve white space, <code> to use a monospace font).


That depends on the browser, the CSS and the user's settings (not
necessarily in that order).

pre { font-family: monospace; }
code { font-family: serif; }

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
8145
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
8
13441
by: Martin Ernst | last post by:
Hello. I want to show HTML source code in my browser (for debugging purposes). Which tag/formatting di i have to use to tell the browser not to render the code but display it as pure text? E.g. I want <p>Hello World</p>
10
2182
by: st4 | last post by:
Help, As part of my family history web site i need to get 150 pages of typed text into some format to display. It just text right now but I would like to add some graphics (photos) and make the text more friendly to read. I am thinking to divide it into smaller chapters and to format it something like a newspaper article. But just learning about HTML, 150 pages just seems like too greater task. Is there a shortcut or another way to do...
2
2450
by: Tor Inge Rislaa | last post by:
Showing an HTML file in part of a Webform Hi I have a Webform with some buttons on the left side of the form. What I want when clicking one of the buttons is to show an HTML document in a part of the Webform (as if it was a Frame page). Any suggestions? (I am an VB programmer) T.I.Rislaa
1
2514
by: ahmad | last post by:
I want to make a particular option's text bold within a list in html, while all other options will get their normal font-weight, How can i do this???????? i tried <b>, <font> tags and style and class attributes to do this. but these didnt work. only text color or background color of a particular option can be changed.
1
1603
by: Max Power | last post by:
HTML reprocessor: how do you get rid of the obese MS-Word (normal or filtered) HTML? I just want all the fancy MS tags removed and replaced with basic ones, or if applicable -- stripped entirely back to HTML 2.0, or HTML 'core' 3.2. It was one thing when my Win95 Netscape's HTML editor bloated up my HTML 2.0 code into moderately efficient HTML 3.2 code. The NETSCAPE Win XP HTML editor rewrote the code into moderately efficient
2
2190
by: Rex | last post by:
Hi, I want to make a particular piece of text BOLD (during runtime) in a textbox. for example: consider a string "The next stage for plaque collection will be at the end of January". I want to make the text "end of january" as bold, while rest of the string be as it is. This needs to be done in a report. Cheers Rakesh
4
9990
by: Luk | last post by:
Hello, i need to get a string / some strings from a html source code (external) url: http://wow.buffed.de/?c=2170577&tab=8 there are under "Scherbenwelt" these strings: Ehrenfeste
2
3835
by: ZBINContact | last post by:
Is there a directive or a command to outline code that I want the Designer to ignore? I am creating a group of user controls with extended self-checking functionality. In each user control, I call a self-check function from a Load event handler, which checks ranges or more complex program-related situations at load time and throws up a messagebox and at times changes the control's properties if the situation demands it. This helps our...
0
8957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9321
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9248
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9193
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8194
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6043
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3268
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.