File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes how to retrieve value of attribute of an xml element tag using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to retrieve value of attribute of an xml element tag using jsp" Watch "how to retrieve value of attribute of an xml element tag using jsp" New topic
Author

how to retrieve value of attribute of an xml element tag using jsp

sweety sandy
Greenhorn

Joined: Apr 05, 2012
Posts: 3
i have my student xml file
<students>
<student name="abc">
<college>pqr</college>
</student>
<student name="def">
<college>xyz</college>
</student>
</students>


please tell me how can i retrieve the value of an attribute name using java server pages
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Use the XML JSTL tags:
Disclaimer: I haven't used the XML tags in a while, so there may be a few mistakes in there.

To get only the first student, use <x:set> instead of <x:forEach>.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sweety sandy
Greenhorn

Joined: Apr 05, 2012
Posts: 3
I need to work using JSP so can you please explain how to retrieve the attribute values using JSP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

sweety sandy wrote:I need to work using JSP so can you please explain how to retrieve the attribute values using JSP

What part of that do you think is not JSP?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Well, I did miss the closing tag of the third comment
sweety sandy
Greenhorn

Joined: Apr 05, 2012
Posts: 3
can you post the entire code
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

sweety sandy wrote:can you post the entire code

Please read NotACodeMill
tejaswini padharthi
Greenhorn

Joined: Apr 11, 2012
Posts: 1
as the provided xml is a user defined you have to use any parser (example: SAX,DOM parser) to read the data in the xml elements and place these elements in an object. you can easily retrieve the data from the object use the needed data in your jsp.
 
Don't get me started about those stupid light bulbs.
 
subject: how to retrieve value of attribute of an xml element tag using jsp