I need to parse an xml chunk which I get without root element, namespace delaration and entity declaration despite including all of the three.
So far I've been using Dom4j
and doing some wrapping around the content but new entites and namespaces keep to appear and the DTD/Schema
of the content is not accessible.
Given that I don't control the source from which I'm getting XML, Is there any kind of java XML parser
that will tolerate these errors?
Abscence of root element
Unbound namespaces
Undeclared entities
You can try using TagSoup which is "forgiving" many errors in the markup.
To work around absence of the root element you can always add your own root element around the XML chunk that you need to parse.
I think all major Java XML parsers have these strict requirements such as a root element. The simple way around all this is to write your own Java XML parser. If you are using the XML purely as a config file then i suggest you look into using Java Properties.
Thanks, Reece
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.