• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading Node from XML

 
sandeep lokhande
Ranch Hand
Posts: 120
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My XML structure is as follows,



I want to extract and get all the values of "Field" from two different nodes InputRecord and OutputRecord,

The code for that which i have written is as,


How could i get separate values of InputRecord and OutputRecord ?

I want to use InputRecord values for some different purpose and OutputRecord for some different than that of InputRecord ,
here in this case i get all the values in the NodeList by,



Please suggest me if there is any option as such for separately getting these values.
thank you in advance.
 
Nick Oz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could either get the parent Node's name then add InputRecord and OutputRecord specific logic based on this value ...

or instead of going straight for Field you could retrieve InputRecord and OutputRecord separately then declare a new NodeList for Field. Naturally if you choose this option I would make this a function with the parent name as an argument (i.e. InputRecord).

Option 1 seems cleaner based on your example but I suppose depending on the size of the XML, number of parents (i.e. InputRecord) and the number of children each parent has it may make more sense to go directly to the parent.

-nick
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our XML forum.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would just use the two XPath expressions "/Connector/Interaction/InputRecord/Field" and "/Connector/Interaction/OutputRecord/Field".
 
sandeep lokhande
Ranch Hand
Posts: 120
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your response, its helped me very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic