Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Element with same name

 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to store the application preferences in an xml file. I am aiming for a structure like this for a JTable for which users can change the list of columns that are displayable.

<table_test>
<columns>
<column name ="col 1" width ="100">
<column name = "col 2" width ="150">
</columns>
</table_test>

- but when I read the file using a DOM parser, my columns element contains only the 'col 2' entry. I can understand that this is happening because the child elements have the same name 'column'. How can I get around this problem. The columns node can have different number of entries at different point of time.

Please help!
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dalia Sultana:
when I read the file using a DOM parser, my columns element contains only the 'col 2' entry. I can understand that this is happening because the child elements have the same name 'column'.
No, you understand incorrectly. The DOM parser will produce a structure that contains all of the "column" elements. It's then up to you to write code that extracts them all, and I expect you didn't do that correctly.

So have another look at your code. Post it here if you are still having problems extracting the data in the way you want.
[ July 31, 2007: Message edited by: Paul Clapham ]
 
Dalia Sultana
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic