• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Reading Node from XML

 
Ranch Hand
Posts: 120
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our XML forum.
 
Sheriff
Posts: 28331
97
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your response, its helped me very much.
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic