• 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

Cannot read childnodes in XML - NEED HELP!

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an xml file and want to read certain tags and attributes..
This is my file


Basically, what i cant figure out is how to read the attribute <Concepto> and others from inside<Conceptos>


In my codeI am able to get <Conceptos> but just not able to read its childs... This is my code.



PLEASE ANY POINTERS WOULD BE GREATLY APPRECIATE IT.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
KeepItDown
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would use the org.w3c.dom methods for Element -

use getElementsByTagName( "Conceptos" )

with one of those Elements getElementsByTagName("Concepto")

with a Concepto Element getAttribute("whatever")

Harold's Processing XML with Java book is available free online, just search. It is loaded with practical examples.

Bill
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
William,
Thanks for the reply... can I get a link, please!
 
Ranch Hand
Posts: 75
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, have you tried getting them directly?

Also, from what I can see, your second concepto has some quotes in the descripcion attribute, that should be escaped.

Claudiu
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, as Paul told you here, don't use == to compare strings. Use the String.equals method.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Claudiu, William;
You have been of great help actually with constructive comments, than you very much! I was able to solve my problem.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic