473,395 Members | 1,335 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,395 software developers and data experts.

XMLTextReader - Issue with sepcial characters &,<,>

RJN
Hi

I'm using XMLTextReader to parse the contents of XML. I have issues when
the xml content itself has some special characters like & ,> etc.

<CompanyName>Johnson & Jhonson</CompanyName>
<EmployeeStrength>> 1000</EmployeeStrength>

When I do a Xmltextreader.read() and then check the contents of the xml
node by XmltextReader.ReadString(), I get an exception when I have
special characters. How do I handle this?

Thanks

rjn


*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
1 2666
RJN,
XMLTextReader only reads "well formed" XML!

| <CompanyName>Johnson & Jhonson</CompanyName>
Is not "well formed" XML...

Change the above to:
<CompanyName>Johnson &amp; Jhonson</CompanyName>

Remember in XML that '&' is "&amp;" while '<' is "&lt;" and '>' is "&gt;".
See "2.4 Character Data and Markup" at
http://www.w3.org/TR/2004/REC-xml-20040204/

Hope this helps
Jay
"RJN" <rj*@yahoo.com> wrote in message
news:u0*************@TK2MSFTNGP12.phx.gbl...
| Hi
|
| I'm using XMLTextReader to parse the contents of XML. I have issues when
| the xml content itself has some special characters like & ,> etc.
|
| <CompanyName>Johnson & Jhonson</CompanyName>
| <EmployeeStrength>> 1000</EmployeeStrength>
|
| When I do a Xmltextreader.read() and then check the contents of the xml
| node by XmltextReader.ReadString(), I get an exception when I have
| special characters. How do I handle this?
|
| Thanks
|
| rjn
|
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #2

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

Similar topics

16
by: Luis P. Mendes | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I only know a little bit of xml and I'm trying to parse a xml document in order to save its elements in a file (dictionaries inside a list)....
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
6
by: barthome1 | last post by:
Hello, My company collects data from non-US sources. We are starting projects where this data will be output in an XML document and passed around to our applications and third party tools. ...
1
by: RJN | last post by:
Hi I'm using XMLTextReader to parse the contents of XML. I have issues when the xml content itself has some special characters like & ,> etc. <CompanyName>Johnson & Jhonson</CompanyName>...
5
by: Mike P | last post by:
I need to put the following code within a <% %> block : response.write "<tr>" &_ "<td bgcolor=eeeeee><a href=""company.asp?company=rs("companyKey")" & "orderby=name"">"&naym&"</a></td>" How...
2
by: David Thielen | last post by:
Hi; I have a node where it is "<w:t> </w:t>" and what I get from XmlTextReader is Element, SignificantWhitespace, EndElement instead of Element, Text, EndElement. Question 1 is why? The text...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
3
by: Goran Djuranovic | last post by:
Hi all, I ran into a problem where my XMLTextReader fails on .Read() when I have "<" character in one of the attribute's values. What I am trying to do is replace illegal characters ("<", "&" ,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...

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.