473,405 Members | 2,167 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,405 software developers and data experts.

what can i do if i want to include "<" or ">" in xml document.

hi everybody,
i am useing some classes which in System.Xml to deal with xml document. what
can i do if the document include "<" or ">"?

Thanks.
Nov 18 '06 #1
3 2139
Escape them to "&lt;" and "&gt;" (excluding the surrounding quotes.

">" is ususally safe even unescaped in most contexts.

Sometimes it becomes necessary to escape the quotes and the apostrophe
characters -- accordingly -- with "&quot;" and "&apos;"

Another character to escape almost always is the ampersand character
itself -- this is escaped as "&amp;"
Cheers,
Dimitre Novatchev
"Steven.Xu" <St******@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
hi everybody,
i am useing some classes which in System.Xml to deal with xml document.
what
can i do if the document include "<" or ">"?

Thanks.

Nov 18 '06 #2
On Sat, 18 Nov 2006 15:36:45 -0800, Dimitre Novatchev wrote:
Escape them to "&lt;" and "&gt;" (excluding the surrounding quotes.

">" is ususally safe even unescaped in most contexts.

Sometimes it becomes necessary to escape the quotes and the apostrophe
characters -- accordingly -- with "&quot;" and "&apos;"

Another character to escape almost always is the ampersand character
itself -- this is escaped as "&amp;"
Cheers,
Dimitre Novatchev
"Steven.Xu" <St******@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
>hi everybody,
i am useing some classes which in System.Xml to deal with xml document.
what
can i do if the document include "<" or ">"?

Thanks.
Also, this is a .NET XML newsgroup, so presumably you're using .NET to
read/write these strings?
If so, XmlTextReader/Writer and XmlDocument both escape the contents
automatically, so you generally don't have to worry about it.

Cheers,
Gadget
Nov 19 '06 #3
Steven.Xu wrote:
i am useing some classes which in System.Xml to deal with xml document. what
can i do if the document include "<" or ">"?
Do you want to create an XML document that contains those characters? As
already pointed out if you use Xml(Text)Writer then escaping is done
automatically if you use the proper API calls (e.g. WriteElementString).

It is not clear whether you want to create such a document or whether
you want to parse an existing document. Parsing markup with unescaped
'<' or '&' content with an XML parser will give you a parse error as the
markup is not well-formed XML.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 19 '06 #4

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

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
3
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going...
10
by: Blue® | last post by:
I would like to call the content of content.htm (containing only HTML codes) into index.htm. This is usually done by renaming index.htm to index.shtml and use this tag: <!--#include...
2
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
1
by: tilt | last post by:
Hello, I use an object element to replace the iframe element in ie, like this: <object id="x_obj" data="http://.../" type="text/html"> <iframe name="x_if" id="x_if"...
10
by: vunet.us | last post by:
What is the workaround of passign a parameter to any included asp file: <!-- #Include File="file.asp" --> This obviously does not work: <!-- #Include File="file.asp?id=123" --> Thank you
23
by: Stanimir Stamenkov | last post by:
I want to find out whether the following usage of the "Bookmark" link type is o.k. An example could be seen at <http://www.geocities.com/stanio/more/horoskop.html>. The text is in Bulgarian and...
36
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.