• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Reading Nested XML attributes

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to read these attributes from XML file




This is my Java code:



Other things are working fine but the output of "SegrigatedQualification" is not accurate like its printing:

whereas that should be:



Here how I am printing:

Best regards

 
Sheriff
Posts: 28371
99
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
Well, first of all, there aren't any attributes in your document at all. You only have elements. It is quite unhelpful if you call things by the wrong name.

As for the order you want things to be written in, I can't tell from that code why you want them in that order. Perhaps if you explained that to yourself you could then write code to do it.

As for your code, if I were asked to maintain it I would throw out all of that DOM navigation and replace it by a much simpler code which used an XPath expression to choose the nodes I wanted to get.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:Well, first of all, there aren't any attributes in your document at all. You only have elements. It is quite unhelpful if you call things by the wrong name.



I not understand at all. attributes are in xml file that is expressed in Java as an "Element". Is that nor right?


As for the order you want things to be written in, I can't tell from that code why you want them in that order. Perhaps if you explained that to yourself you could then write code to do it.



I think this is very simple code to read the data from XML file and to present it in a order that we like. All the problem I am facing is related to loop that is inside EducationSplit as there may be many education records in a CV


As for your code, if I were asked to maintain it I would throw out all of that DOM navigation and replace it by a much simpler code which used an XPath expression to choose the nodes I wanted to get.


This is very new to me but I have downloaded its API and certainly will study.

Thanks for your reply

regards
 
Paul Clapham
Sheriff
Posts: 28371
99
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


That element has one attribute. The name of the attribute is "abc" and its value is "def". So... elements are not attributes. Don't go around calling elements attributes, that just confuses things.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Paul Clapham I am thankful to you from the bottom of my heart. You saved my too much time by providing advice of XPath

Everything is done now. Appreciated!!
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic