472,119 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to detect the Invalid XML Character ?

Hi,

We are using SAXParser (xerces) for parsing an xml with utf-8 encoding.
For some special character it gives SAXException with error message -
"The invalid character is found in the document ". But for other errors
also it gives the same Exception only with different message.
Is there any way to detect that the error is because of the invalid
character in xml ?

Or

if there is any profile to check whether the xml contains any invalid
character or not??

thanks in advance

sachin

Jun 12 '06 #1
2 3400
sa********@gmail.com wrote:
Hi,

We are using SAXParser (xerces) for parsing an xml with utf-8 encoding.
For some special character it gives SAXException with error message -
"The invalid character is found in the document ". But for other errors
also it gives the same Exception only with different message.
Is there any way to detect that the error is because of the invalid
character in xml ?


Run a standalone parser that gives you line number and character number,
eg onsgmls, rxp, etc.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jun 12 '06 #2
Peter Flynn wrote:
Is there any way to detect that the error is because of the invalid
character in xml ?


Unfortunately, SAXExceptions don't carry any sort of standard code to
describe the failure. Check your specific parser implementation; it
_might_ have added this information... but that will be a nonportable
solution, if so.

Simplest answer may in fact be to implement your own parser which does
present that information, or to get hold of an open-source parser like
Xerces and add this feature to it. Again, the problem is that this isn't
portable to other parsers unless they have the same tweak.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jun 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by R. Rajesh Jeba Anbiah | last post: by
9 posts views Thread by Safalra | last post: by
13 posts views Thread by Michal | last post: by
reply views Thread by Robert Boone | last post: by
6 posts views Thread by rrs.matrix | last post: by
20 posts views Thread by FAQ server | last post: by
2 posts views Thread by lawrence k | last post: by
7 posts views Thread by Peter | 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.