Java parses XML file experience with DOM

zhaozj2021-02-12  189

Originally prepared to use SAX parsing, the result saw that SAX is an event activation mechanism, only startDocument (), startElement () (), endDocument (), enddocument, character (), did not find a good method to get the best in the case T> contains data. So the DOM parsing DOM parsing is slower than the large file resolution, and one node is traversed. So only if you have to use it. Two classes of Node, Nodelist are mainly used during this analysis. The method is only a few ways to getnodeName (), getnodeType (), getnodevalue ().

Remarks: This traversal is a node to find, then filter, as long as you are careful to add perseverance and use the correct function, there is a time problem. There is no technical difficult point. It is worth noting that: nodelist.item (i) where I value is calculated in the odd number. It may be because of 2 overall as 2 items ...

转载请注明原文地址:https://www.9cbs.com/read-6636.html

New Post(0)