Hi all can any one tell me is it possible 开发者_如何学Cto convert any XML file file to equivalent java object using java?
You want a DOM parser. There are many around, a Google search for "Java DOM parser" will help you. Take this page for example.
You are probably looking for JAXB.
Use XStream library it is quite simple: http://x-stream.github.io/tutorial.html
// object -> XML -> File
XStream xstream = new XStream(driver);
String data = xstream.toXML(metaData);
// XML -> object
XStream xstream = new XStream(new JettisonMappedXmlDriver());
YourClass obj = (UourClass)xstream.fromXML(jSON);
You could use unmarshall function in castor.
Let me add another to the collection.
Have a look at the Apache Jakarta Digester this is what Tomcat uses to automap XML files (like server.xml).
精彩评论