File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading Nested XML attributes

 
Farakh khan
Ranch Hand
Posts: 833
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
Paul Clapham
Sheriff
Pie
Posts: 20206
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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: 833
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20206
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • 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: 833
  • 0
  • Mark post as helpful
  • send pies
  • 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!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic