This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am looking out for a tool or library for following requirement.
1] I have XML file e.g. something like this:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
I don't have XSD file of this XML .
2] I don't have 'Person' java class .
Is there any tool or library available which will parse XML file and at runtime build Java class 'Person' with getter and setter for Tags like getFirstName() and setFirstName() and so on .
Similarly , it will populate the value of 'Person' class with values in xml e.g setting 'firstname' in 'Person' class as 'Joe' and so on ?
How would your code use those classes if they didn't exist at compile time? They couldn't implement some common interface, as each XML file would have different tags, correct?
Maybe take a step back, and tell us what you're trying to achieve. For example, would this code really be expected to handle unknown XML formats? If so, what does it do?
If you did have a Person class, then you could use one of several available libraries, such as Apache Commons Digester, to populate them, or a more general API such as JAXB that can do two-way mapping.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Build and Populate java classes at Runtime from XML file