我需要检查给定的 XML 是否格式正确,例如所有标签是否正确关闭,并且 XML 末尾没有垃圾。而且我还需要它来报告 XML 中的所有错误。我需要在java中做这个验证
例如
<Hello>
<title>Today is a wonderful day </title>
<car>
<type>SUV
<car>
<type>van</type>
</car>
</Hello>
</type>
</car>
Run Code Online (Sandbox Code Playgroud)
所以上面的xml一定会报文件尾有垃圾和car和type标签在给定的行号没有正确关闭的错误