Java: XML to Object (or Array)

前端 未结 5 1576
清酒与你
清酒与你 2021-01-15 08:04

How could I convert a XML Document to a Java Object (or Array)? I readed the XML like this:

DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInsta         


        
5条回答
  •  死守一世寂寞
    2021-01-15 08:29

    I would look at JAX/B, which gives a way to "bind" between Java objects and XML representations.

    I've got a tiny write-up of doing it with Rational Eclipse-based tooling here, but there appear to be (never used them myself) straight Eclipse plugins too, for example this.

    Indeed writing JAX/B by hand is possible, gets a bit dull for complex XML, but annotations are quite easy.

提交回复
热议问题