What is the best solution for generating XML.
My goal is to create some simple XML files from code. I am going to implement a simple custom implementation of XML Builder based on StringBuffer. On the other hand, there are several libraries like http://code.google.com/p/java-xmlbuilder/ and http://code.google.com/p/xmltool/ which has a good DSL but I donβt confident in performance.
Since my goal is to build a fairly simple XMLBuilder with great performance, I think Iβll create my own solution. It will show:
- Good Java-DSL for XML constructs (tagging mostly)
- Great performance based on StringBuffer.
- Outlier control of String data when adding XML tags.
- Indenting
Please suggest if I am mistaken about performance expectations and it might be better to use ready-made libraries.
UPDATE. Why I think that the performance of standard xml developers is not very good.
Standard XML builders use Document Builder Factory and work with classes behind the scenes. Also, these classes are optimized for all users. For example, I do not need namespace support, etc.
<?xml version="1.0" encoding="utf-8">
<root>
<testdata>value</testdata>
</root>
</xml>
Consider the very simple XML code above. If you create with standard tools, it will require a lot of work to make this simple XML. I find it better to just create it yourself using String.
2. , , XML .
3. ! , , ββ "". - DSL XML XML.
Java DSL XML XML, XStream, .
4. JAXB. XStream vs JAXB , JAXB , XStream. JAXB , . JAXB, XStream , JAXB , .