How to detect the Invalid XML Character ?

Discussion in 'XML' started by sachinik19@gmail.com, Jun 12, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Peter Flynn Guest

    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/
     
    Peter Flynn, Jun 12, 2006
    #2
    1. Advertising

  3. 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
     
    Joe Kesselman, Jun 13, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cgbusch
    Replies:
    6
    Views:
    7,510
    Mike Brown
    Sep 2, 2003
  2. Mark

    Invalid XML character

    Mark, Aug 18, 2004, in forum: XML
    Replies:
    5
    Views:
    5,638
    Richard Tobin
    Aug 18, 2004
  3. Kaidi
    Replies:
    3
    Views:
    5,893
    Kaidi
    Sep 27, 2004
  4. Marco Montel

    invalid XML character

    Marco Montel, Dec 7, 2004, in forum: XML
    Replies:
    6
    Views:
    10,523
    David Carlisle
    Dec 8, 2004
  5. kevin
    Replies:
    0
    Views:
    976
    kevin
    Jan 16, 2008
Loading...

Share This Page