• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Searching XML elements using text and work with siblings

 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I am building a XML reader class DOM.

Does anyone have a link that has some code where

the text from a JComboBox.selectedItem()("text")

for example or any text is used to find a Node in a the DOM document

and then work with that nodes siblings?
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why I can only get the first child below the element I am working with.

There are actually 51 in the XML doc.

Is there a way to retrieve these children?




output
run:
The root element is data.

The param sent to class: cmaj
The attr retrieved: keyname="cmaj"
children: 3
children: 3
children: 3
The root element is data.

The param sent to class: cmaj
The attr retrieved: keyname="cmaj"
children: 3
children: 3
children: 3
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
51? No, it's pretty clear from that code that you have a node with three children. Not 51. Then you run a loop which prints that information out once for each of the children. And that's all it does, the rest of what you have there is a comment. It might look like Java code but it doesn't get executed.
 
James Howerton
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes partially correct. I it also clear that my XML actually has 50+- elements under the element I am looking for. So it is simple! I have to find the element that has all the child elements I am looking for. And then get each value with the code that is commented out.

I usally just disregard any code that is commented out it is not really relevant to to guest ion.

Thanks for your time
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Howerton wrote:I usally just disregard any code that is commented out it is not really relevant to to guest ion.


Indeed. In which case you shouldn't have posted it. Posting it leaves open the possibility that you might not have noticed that it was a comment -- which does happen to people -- so it's a distraction from the question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic