471,336 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 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 2511
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Luis P. Mendes | last post: by
1 post views Thread by Christian Schmidbauer | last post: by
2 posts views Thread by Donald Firesmith | last post: by
6 posts views Thread by barthome1 | last post: by
5 posts views Thread by Mike P | last post: by
2 posts views Thread by David Thielen | last post: by
7 posts views Thread by John Nagle | last post: by
reply views Thread by rosydwin | last post: by

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.