Himanshu Yadav
Himanshu Yadav

Reputation: 13587

Efficient way to search for an element name in DOM4j document

What is the most efficient to search an element?
Would it take to traverse through the complete DOM4j document?
Should I use XPATH here?
I am actually comparing two XML documents. Will iterate through first xml one by one and search for it the second xml document.
It is not a straightforward comparison. I would be comparing name attribute value with second xml's elements. And if first xml has any name such as name="xx.yy" then I need to look for <xx> <yy></yy> </xx> in second xml.

Upvotes: 0

Views: 660

Answers (1)

Antoniossss
Antoniossss

Reputation: 32507

Maybe you could use Jsoup for this? I don'k know what kind of comparison are you up to, but with Jsoup you could simply select all nodes from both XMLs and iterate over both collections in one loop. Jsoup is very effective and easy to use if you need to select random node just by its attribute (any attribute) tag name or content.

Upvotes: 1

Related Questions