[英]Java reading complicated xml files Java
How I can read 'people=400000' and "Lubljana" data records from this xml file in Java?我如何从 Java 中的这个 xml 文件中读取“people=400000”和“Lubljana”数据记录?
And here is the sample of xml file which I already used.这是我已经使用过的 xml 文件示例。
<?xml version="1.0"?>
<countrys>
<country people="3500000">
<naziv>Slovenija</naziv>
<glavnigrad people="400000">
<naziv>Ljubljana</naziv>
</glavnigrad>
<povrsina jedinica="km2">51129</povrsina>
<moneta naziv="KM" />
</country>
</countrys>
You basically have two options:你基本上有两个选择:
Benefits: Provides object model in Java that can be easily referenced.优点:在Java中提供了易于引用的对象模型。
Drawbacks: Memory intensive for large XML structures.缺点:大型 XML 结构需要大量内存。 Potentially slower.
可能更慢。
https://howtodoinjava.com/xml/read-xml-dom-parser-example/ https://howtodoinjava.com/xml/read-xml-dom-parser-example/
Benefits: Less memory usage, potentially faster.好处:更少的内存使用,可能更快。
Drawbacks: Potential confusion in identifying nodes and/or duplicates outside of uniform tree structure.缺点:在统一树结构之外识别节点和/或重复项时可能会混淆。
https://howtodoinjava.com/xml/sax-parser-read-xml-example/ https://howtodoinjava.com/xml/sax-parser-read-xml-example/
You should research and try each approach.您应该研究并尝试每种方法。 Other approaches are derivatives of these basics.
其他方法是这些基础知识的衍生物。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.