Native Java API for Checking Valid XML

前端 未结 1 480
醉梦人生
醉梦人生 2021-01-28 01:04

How do you determine whether a Document object in Java contains valid XML. Is this checked when the object is constructed?

I can\'t appear to find any infor

相关标签:
1条回答
  • 2021-01-28 01:43

    Use the Java DOM API. It can handle any valid XML document. A valid document will give no exception. You need no external libraries for DOM.

    In case of an error the exception message looks like this:

    [Fatal Error] MyXMLFile.xml:6:2: The end-tag for element type "lastname" must end with a '>' delimiter.
    The end-tag for element type "lastname" must end with a '>' delimiter.
    BUILD SUCCESSFUL (total time: 0 seconds)
    
    0 讨论(0)
提交回复
热议问题