XOM v / s javax.xml.parsers

I want to read a simple .i XML file. An easy way to make Xml in Java

There are also a few parsers that just wanted to make sure that the benefits of using the XOM parser over the suns parser

Any suggestions?

+4
source share
3 answers

XOM is extremely fast compared to the standard W3C DOM. If this is your priority, there is nothing better.

However, it is still a DOM type API, and therefore it is not memory efficient. This is not a replacement for SAX or STAX.

+6
source

You might want to check out this question about the best XML library and its top (XOM) answer; Lots of details about the benefits of XOM. (Leave a comment if something is unclear, Peter Ε tibranΓ½ seems to know XOM inside and out.)

As already mentioned, XOM is very fast and easy in most tasks compared to standard javax.xml. For example, see this post for a simple way to read in an XML file in Java. I put together some nice examples that make XOM look pretty good (and javax.xml is pretty awkward). :-)

So personally, I came as XOM after the evaluation (as you can see in the related posts); for any new Java project, I would most likely choose XOM for XML processing. The only drawback I discovered is that it does not directly support streaming XML (unlike dom4j, where I came from), but with a simple workaround , it might just work just fine.

+4
source

How do you need to access your data?

If it is a single pass, then you do not need to build a tree in memory. You can use SAX (fast, simple) or StAX (faster, not really like that).

If you need to keep the tree in memory for navigation, XOM or JDOM is a good choice. DOM is the choice of the last resort, be it level 1, 2 or 3, with or without extensions.

Xerces, which is a parser included in Java (although you should get an updated version from Apache and not use the one bundled with Java, even in version 6.0), also has a proprietary XNI interface.

If you want to link other finished parts in a chain, often SAX or StAX work well, as they can create their own model in memory. For example, the Saxon XSLT / XQuery engine works with the DOM, SAX, or StAX, but is built inside TinyTree (by default) or DOM (optional). DataDirect XQuery also works with SAX, StAX or DOM, but actually likes StAX.

+1
source

Source: https://habr.com/ru/post/1286288/


All Articles