By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,592 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,592 IT Pros & Developers. It's quick & easy.

XMLTextReader - Issue with sepcial characters &,<,>

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.