简体   繁体   English

如何使用Java中的sax解析器解析xml?

[英]how to parse xml using sax parser in java?

在循环中,每次我需要解析一个新的xml时,我都必须解析xml中的某些特定节点,如果它们具有值,则将它们复制到另一个文件中,否则继续进行直到最后一个xml,该怎么做?

The essence of Sax is that you don't own the flow of control: when you say "in a loop", you are hinting that you want the flow of control. Sax的本质是您不拥有控制流:当您说“循环”时,表明您想要控制流。 With Sax, the parser calls you when it's ready to do so. 使用Sax,解析器会在准备就绪时调用您。 If you want to be in control, try using a pull parser (Stax, for example Woodstox). 如果要控制自己,请尝试使用拉式解析器(Stax,例如Woodstox)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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