473,400 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

Including HTML Tags in XML Text

I am fairly new to XML, I have an XML document that holds configurations for
an ASP.NET application, within the configuration XML File
I have a line of text that will feed into a lable on a web form. I would
like to be able to include html breaks <BR> within the text.

Is this possible and if so, how is it done?

XML:
<WebText>
This Line of Text will show in Lable, Put a Break Here <BR>
Continue on with text in next line
</WebText>

Thanks in Advance,
Rick
Nov 12 '05 #1
4 1562
Rick wrote:
I am fairly new to XML, I have an XML document that holds configurations for
an ASP.NET application, within the configuration XML File
I have a line of text that will feed into a lable on a web form. I would
like to be able to include html breaks <BR> within the text.

Is this possible and if so, how is it done?


There are many ways. Including some obvious:
1. Use CDATA:
<WebText>
<![CDATA[
This Line of Text will show in Lable, Put a Break Here <BR>
Continue on with text in next line
]]>
</WebText>

2. Escape all < and & characters:
<WebText>
This Line of Text will show in Lable, Put a Break Here &lt;BR>
Continue on with text in next line
</WebText>

3. Use XHTML instead:
<WebText>
This Line of Text will show in Lable, Put a Break Here <BR/>
Continue on with text in next line
</WebText>
--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2
Thanks for the help, I should have thought of the obvious, but I believe
I'll use the CDATA.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
Rick wrote:
I am fairly new to XML, I have an XML document that holds configurations
for an ASP.NET application, within the configuration XML File
I have a line of text that will feed into a lable on a web form. I would
like to be able to include html breaks <BR> within the text.

Is this possible and if so, how is it done?


There are many ways. Including some obvious:
1. Use CDATA:
<WebText>
<![CDATA[
This Line of Text will show in Lable, Put a Break Here <BR>
Continue on with text in next line
]]>
</WebText>

2. Escape all < and & characters:
<WebText>
This Line of Text will show in Lable, Put a Break Here &lt;BR>
Continue on with text in next line
</WebText>

3. Use XHTML instead:
<WebText>
This Line of Text will show in Lable, Put a Break Here <BR/>
Continue on with text in next line
</WebText>
--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #3


Rick wrote:
I should have thought of the obvious, but I believe
I'll use the CDATA.


If CDATA suits your needs then use it but be aware that if you ever
wanted to process the XML with XML tools like DOM or XSLT the whole HTML
markup is only seen as text without the structure the HTML elements define.
Thus if you want to process the HTML inside of the XML with XML tools
then it is much smarter to use XHTML inside of the XML e.g.

<WebText>
This Line of Text will show in Lable, Put a Break Here <br
xmlns="http://www.w3.org/1999/xhtml" />
Continue on with text in next line
</WebText>

that way your content has structure which an XML parser or an XML tool
like DOM or XSLT sees and exposes to processing.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #4
Rick wrote:
Thanks for the help, I should have thought of the obvious, but I believe
I'll use the CDATA.


And don't forget that CDATA section cannot contain "]]>" characters -
you have to replace them with "]]>]]><![CDATA[" or escape as ]]&lt;
Actually if you use XmlTextWriter or XmlDocument to build yoru XML, they
will take care of all this syntax stuff.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #5

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

Similar topics

0
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
82
by: Eric Lindsay | last post by:
I have been trying to get a better understanding of simple HTML, but I am finding conflicting information is very common. Not only that, even in what seemed elementary and without any possibility...
5
by: acord | last post by:
Hi, I m getting annoying display problem when placing javascript tags in a html page. Should the javasscript tags placed at the beginning of a html page before anything start? or placed between...
13
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
7
by: Xah Lee | last post by:
Summary: when encountering ex as a unit in css, FireFox (and iCab) did not take into account the font-family. Detail: http://xahlee.org/js/ff_pre_ex.html Xah xah@xahlee.org ∑...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
10
by: Robert Huff | last post by:
Can someone offer suggestions why, on the same server (Apache 2.2.8), this works <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang="en-US"> <head> <link rel=stylesheet...
17
by: V S Rawat | last post by:
I joined this ng and tried to post my first message that had a small php code (HTML and all). my newsserver aioe.net rejected the post saying "HTML Tags". My message was in text format, not in...
14
by: Andy B | last post by:
I need to create a regular expression that will match a 5 digit number, a space and then anything up to but not including the next closing html tag. Here is an example: <startTag>55555 any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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 project—planning, coding, testing,...

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.