Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate xml in Java?

Tags:

java

xml

sax

Please, tell me, how to generate XML in Java? I couldn't find any example using SAX framework.

like image 799
Jake Badlands Avatar asked Sep 09 '26 21:09

Jake Badlands


1 Answers

Try Xembly, a small open source library that wraps native Java DOM with a "fluent" interface:

String xml = new Xembler(
  new Directives()
    .add("root")
    .add("order")
    .attr("id", "553")
    .set("$140.00")
).xml();

Will generate:

<root>
  <order id="553">$140.00</order>
</root>
like image 106
yegor256 Avatar answered Sep 11 '26 09:09

yegor256



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!