Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading xml file with JDOM  RSS feed

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, i am trying to read an xml file but I am getting stuck with some tags and need some help.

This is the file I am trying to read


the parte where I am stuck is reading the 2 lines inside <cfdi:Impuestos>, can somebody help, especially where it says GETVALUE

This is my java code, just to start...I will make it better later, just getting the hand of how to read data.
 
Ranch Hand
Posts: 708
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we stick to method akin to dom childNodes() method where in JDom2 it would read as children() method, you have to successively go deeper in level. In this case, go twice in depth. This is how you can do that.

In a sense, you can do it more directly without explicitly spelling out the detail of traversing level-by-level... In dom there is getElementsByTagName() method and there is also xpath as a derivative technology. In JDom2, it takes form in Filter class and its sub-classes. This is how you can proceed with the ElementFilter.

Now you have two methods to do it.
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!