[Advanced-java] How do I retrieve attributes in
correct order from a DOM?
Kathy Van Stone
kvs at acm.org
Thu Apr 13 09:52:41 PDT 2006
At 11:15 AM 4/13/2006, Prashant Parashar wrote:
>I am trying to retrieve database query result in XML and the columns
>are returned as attributes. I know the better way is to get them as
>elements but now can't go back...
>and correct order is the order in which they appear in XML text -
><element1 attr1="v1" attr2="v2" attr3="v3"........ />
What I am saying is that the definition of XML states that the order
is unimportant, so you should not expect *any* parser (except one you
create) to maintain the order in the printed document.
In JDBC you can retrieve row data either in order or by specifying
the column name, so it should not be necessary to know the column
name. If inserting data it is also possible to use name instead of
numbers to specify values.
You may also want to look at dbunit (www.dbunit.org) which is a
testing extension, but they handle database data in that same format.
-Kathy Van Stone
kvs at acm.org
More information about the Advanced-java
mailing list