基于Fluent Interface设计的xml工具-xmlzen

今早,发现了一个非常轻量级的xml解析生成工具。整个工具就2个类,一个XmlBuilder,一个XmlSlicer。
最重要的是,它是基于Fluent Interface设计的(连贯接口设计, 大大简化编码量)。

工具最大的特色如作者在主页上所说的一句话,Forget W3C, and terrible APIs。
下面是摘自官方的一个关于生成xml的例子:

Code

String xml = XmlBuilder.newXml("UTF-8", true)
    .openTag("xml").withAttribute("id", 1)
        .openTag("thisishow")
            .withValue("you can build")
        .closeTag()
        .openTag("your").withAttribute("xml", "nicely").toString(true);

xmlzen example

项目主页:http://code.google.com/p/xmlzen/

转载请注明原文链接:http://kenwublog.com/light-weight-xml-slicer-and-builder

2009/10/26 | Posted in Development Skills
No comments yet.

Leave a comment

Attention: Java syntax highlighting is enable. For example: <pre lang="java"> class A {} </pre>