I have used dom4j to do this in a proof of concept. Basically a "manual"
parse of the XML structure to construct
an object to be persisted via a dao.
SAXReader xmlReader = new SAXReader();
Document document = xmlReader.read(file);
Element root = document.getRootElement();
String name = root.getName();
log.debug("root: " + root.getName() +
" = " + root.getText());
if ( name.equals("ConfigurationItem") ) {
Iterator elementIterator =
root.elementIterator();
String source = null;
String destination = null;
String type = null;
String version = null;
String id = null;
while ( elementIterator.hasNext() ) {
Element element =
(Element)elementIterator.next();
log.debug("element: " +
element.getName() +
" = " + element.getText());
if (
element.getName().equals("Source") ) {
source = element.getText() ;
} else if (
element.getName().equals("Destination") ) {
destination = element.getText() ;
} else if (
element.getName().equals("Type") ) {
type = element.getText() ;
} else if (
element.getName().equals("Version") ) {
version = element.getText() ;
} else if (
element.getName().equals("Id") ) {
......
Matt Raible wrote:
On 12/17/06, KiranRredy <[EMAIL PROTECTED]> wrote:
Thanks for your information.
Have you written any custom java code to read person data from
'metadata/sql/sample-data.xml file'.
and where you used DbUnit tool.
No, we're just using DbUnit's API for this. Spring's Resource API
allows an easy way to load files, but if you need to parse XML, you'll
need to use another API.
Matt
--
View this message in context:
http://www.nabble.com/can-we-get-data-from-xml-file-in-Appfuse%28-with-out-writing-extra-classes%29-tf2832859s2369.html#a7914983
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]