• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Element with same name

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. Thank you.
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic