Hi..,
While parsing a XML files I need to hold some of the values in an
array till the end of the iteration. After that I need to dump the
values in the DB table.
Here is an eg.
- These are the 4 values I want to hold from each file after I parse them.
Name, dept_no, employee_id, state
How do i create an array?
Matt Humphrey - 18 May 2006 19:56 GMT
> Hi..,
>
[quoted text clipped - 7 lines]
>
> How do i create an array?
What you're asking for is something like
String [] values = new String [4];
values[0] = name;
values[1] = dept_no;
but this is a poor way to go because it obscures the names of the fields.
It sounds more like you need a class, as is
class Employee {
String name;
String dept_no;
String employee_id;
String state;
}
create a new Employee each time you encounter the values. There are some
automated systems for doing this, but I havn't used them.
Alternatively, if you could put the fields into a map, as in
Map map = new HashMap ();
map.put ("name", name);
map.put("dept_no", dept_no);
etc.
I don't recommend this unless you are assured there is a an exact map
between your incoming data and your database schema.
Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/