简体   繁体   中英

Reading data from XML file in Java

I dont know how to read data from such XML file. Lets say i want to read every every GUID and userID. How do i do it?

Here is part of XML: http://pastebin.com/7B25eyFz

您可以使用Xstream

Look into SAX Parser . Also, do a search for your terms - there are a ton of questions about this topic.

您是否阅读了Java教程中有关XML线索

You should use an XML library like XOM . You can then use it to query the XML document using XPATH. XOM offers a tutorial .

如果您的xml文件是基于树的,则使用DOM,如果未嵌套,则使用SAX,比DOM快。

添加到@user651407点,如果您只想读取XML然后去SAX ,它将以串行方式解析XML ,这样速度更快,但是如果您想执行更复杂的操作(例如添加,更新或删除节点),请继续DOMDOM有局限性
1. required more memory as entire XML is loaded at a time.
2. Slow in processing as it is a tree based parser.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM