XPath.evaluate performance slows down (absurdly) over multiple calls

前端 未结 5 1039
再見小時候
再見小時候 2020-12-08 10:28

I am trying to use the javax.xml.xpath package to run XPath expressions on a document with multiple namespaces, and I\'m having goofy performance problems.

My test d

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-08 11:20

    Try cloning the node (so you won't have unnecessary references from its ancestors)

    Node singleNode = nodes.item(i).cloneNode(true);
    

    If you remove children, you will lose references and only get half of the nodes you want to process.

提交回复
热议问题