469,578 Members | 1,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

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 3319
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
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.