• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sweety sandy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>.
 
sweety sandy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Pie
Posts: 20659
64
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I did miss the closing tag of the third comment
 
sweety sandy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you post the entire code
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sweety sandy wrote:can you post the entire code

Please read NotACodeMill
 
tejaswini padharthi
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic