Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
XML and Related Technologies
How to print xml element in asc or desc order
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello,
My Code:
//----- NodeList titleNameList = resumeElement.getElementsByTagName("TitleName"); if (titleNameList.getLength() == 0) { System.out.println("I am here-1"); } else{ Element titleNameElement = (Element)titleNameList.item(0); NodeList textTNList = titleNameElement.getChildNodes(); titleName=((Node)textTNList.item(0)).getNodeValue().trim(); resumeDetails.put("1", inputField("titleName",titleName,"Title Name")); } //----- NodeList firstNameList = resumeElement.getElementsByTagName("FirstName"); if (firstNameList.getLength() == 0) { System.out.println("I am here-2"); } else{ Element firstNameElement = (Element)firstNameList.item(0); NodeList textFNList = firstNameElement.getChildNodes(); firstName=((Node)textFNList.item(0)).getNodeValue().trim(); resumeDetails.put("2", inputField("firstName",firstName,"First Name")); } //////////////////////////// Collection c = resumeDetails.values(); Iterator itr = c.iterator(); while (itr.hasNext()) { out.println(itr.next()); } //////////////////////////
This prints the output randomly. How can I control it to print elements in ascending or descending order?
Thanks & best regards
Paul Clapham
Marshal
Posts: 28193
95
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I would put the data into a suitable collection and sort it in whatever order you need. You have used a collection already, but perhaps you didn't choose the right collection (I don't see where you declare it). And you certainly didn't sort it.
Farakh khan
Ranch Hand
Posts: 851
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear Paul Clapham,
Thanks a lot. This has fixed my problem
Best regards
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Parsing Nested XML Nodes
parsing XML in java
java.lang.NullPointerException
help with web service to display xml file contents using netbeans
Reading Nested XML attributes
More...