1. Overview
1.概述
This is a guide to working with XML in Java.
这是在Java中使用XML的指南。
We’ll go over the most common Java XML processing libraries – for both parsing and binding.
我们将介绍最常见的Java XML处理库 – 用于解析和绑定。
2. DOM Parsers
2.DOM解析器
Simply put, a DOM parser works on the entire XML document, loads it into memory and constructs a tree representation of the document.
简单地说,DOM解析器在整个XML文档上工作,将其加载到内存中并构建一个文档的树状表示。
2.1. Useful Resources
2.1.有用的资源
- Working with XML Files in Java Using DOM Parsing
- Write an org.w3.dom.Document to a File
- Pretty-Print XML in Java
- Intro to XPath with Java
- Modifying an XML Attribute in Java using dom4j
3. SAX Parser
3.SAX解析器
A SAX parser is an event-based parser – it parses the XML document using callbacks without loading the whole document into memory.
SAX解析器是一个基于事件的解析器–它使用回调来解析XML文档,而不把整个文档加载到内存中。
3.1. Useful Resources
3.1.有用的资源</span
4. StAX Parser
4.StAX解析器
A StAX Parser is median between DOM and SAX parser.
StAX解析器是DOM和SAX解析器之间的中位数。
4.1. Useful Resources
4.1.有用的资源</span
5. JAXB
5 JAXB
JAXB – Java Architecture for XML Binding – is used to convert objects from/to XML.
JAXB – Java Architecture for XML Binding – 用于从XML转换对象。
JAXB is a part of the Java SE platform and one of the APIs in Jakarta EE.
JAXB是Java SE平台的一部分,是Jakarta EE的API之一。
5.1. Useful Resources
5.1.有用的资源
6. XStream
6.XStream
XStream is a simple library to serialize objects to/from XML.
XStream是一个简单的库,用于将对象序列化为/来自XML。
6.1. Useful Resources
6.1.有用的资源</span
- XStream User Guide: Converting XML to Objects
- XStream User Guide: Converting Objects to XML
- Remote Code Execution with XStream
7. Jackson XML
7.Jackson XML
Jackson XML is an extension of the Jackson JSON processor for reading and writing XML encoded data.
Jackson XML是Jackson JSON处理器的一个扩展,用于读写XML编码的数据。
7.1. Useful Resources
7.1.有用的资源</span
- Official Website
- Github
- Jackson XML databind Wiki
- Jackson XML annotations
- XML Serialization and Deserialization with Jackson
- Convert XML to JSON Using Jackson
8. Apache CXF Aegis
8.Apache CXF Aegis[/strong
Aegis is a data binding or a subsystem that can map between Java objects and XML documents described by XML schemas.
Aegis是一个数据绑定或一个子系统,可以在Java对象和XML模式描述的XML文档之间进行映射。
8.1. Useful Resources
8.1.有用的资源</span
9. JiBX
9.JiBX
JiBX is a tool for binding XML data to Java objects. It provides solid performance compared to other common tools such as JAXB.
JiBX是一个用于将XML数据绑定到Java对象的工具。与其他常见的工具如JAXB相比,它提供了坚实的性能。
9.1. Useful Resources
9.1.有用的资源</span
10. XMLUnit 2
10.XMLUnit 2
XMLUnit 2.x is a powerful library that helps us test and verify XML content, and comes in particularly handy when we know exactly what that XML should contain.
XMLUnit 2.x是一个强大的库,它帮助我们测试和验证XML内容,当我们确切地知道该XML应该包含什么时,它就特别方便了。
10.1. Useful Resources
10.1.有用的资源
11. Conclusion
11.结论
This was a quick intro to the XML ecosystem in Java.
这是对Java中的XML生态系统的一个快速介绍。
Use this as a guide to learn more about doing XML work and getting a high-level view of the Java XML landscape.
以此为指南,了解更多关于从事XML工作的信息,并获得Java XML领域的高级视图。
We also have a collection of articles on this topic, if you wish to see links to all our XML content in one place.
我们还有一个关于这个主题的文章集,如果你希望在一个地方看到我们所有XML内容的链接。