xml in JSP

xml in JSP

View Answers

March 9, 2009 at 7:10 AM

Hi Friend,

I am sending you a JSP code which will show all the students name from the "student" tag as defined in the "roseindia.xml".

Here is the roseindia.xml file as follows :

<?xml version="1.0" encoding="ISO-8859-1"?>
<roseindia>
<student>
Amit
</student>

<student>
Vineet
</student>

<student>
Sumit
</student>

<student>
Suneet
</student>
</roseindia>
=========================

parsingxml.jsp

<%@page import="org.w3c.dom.*, javax.xml.parsers.*" %>
<%
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse("http://localhost:8080/JSPExample/roseindia.xml";);
%>
<%!
public boolean isTextNode(Node n){
return n.getNodeName().equals("#text");
}
%>
<html>
<head><title>Parsing of xml using DOM Parser</title></head>
<body>
<h2><font color='green'>Name of Students</font></h2>
<table border="2">

<%
Element element = doc.getDocumentElement();
NodeList personNodes = doc.getElementsByTagName("student");
for (int i=0; i<personNodes.getLength(); i++){
Node emp = personNodes.item(i);
%>
<td><%= emp.getFirstChild().getNodeValue() %></td>
<%
}
%>
</table>
</body>
</html>


Thanks
Rose India Team









Related Tutorials/Questions & Answers:
XML to JSP
an xml file and display the data into jsp file...XML to JSP  How to access the following XML tag Title tag in JSP   Please visit the following link: http://www.roseindia.net/jsp
XML with JSP - XML
XML with JSP  Hai all,, I have a doubt..is it possible to submit jsp form data in to xml... i mean after filling the HTML form when i give submit... the values in to my jsp from XMl..pls help me in this issue
Advertisements
XML in JSP - JSP-Servlet
XML in JSP  How to read XML in our JSP page. send me any exmple code.  Hi friend, We can read an XML file in the JSP using DOM parser. Here is the link which will help you to understand XML file parsing (reading
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
xml in JSP - JSP-Servlet
xml in JSP  This is my code.... Now I am getting only first node. I......   Hi Friend, I am sending you a JSP code which... ========================= parsingxml.jsp Parsing of xml using DOM Parser
jsp and xml - XML
jsp and xml  An example of retrive data from xml using JSP.  HiThis retrive data from xml using jsp.airLineShedule.jsp<%@ page...;/body></html>airLineShedule.xml<?xml version="1.0" encoding
XML - JSP-Servlet
XML  How to read XML of a website to display that data in our JSP page. Send me any sample code.  Hi friend, For solving the problem visit to : http://www.roseindia.net/jsp/parsing-xml.shtml Thanks
write xml file with jsp useBean - JSP-Servlet
write xml file with jsp useBean  how to write into xml files with jsp... allows our application to obtain a Java XML parser. DocumentBuilderFactory... an org.w3c.dom.Document from XML. Save the xml file at bin file of C:\apache-tomat-5.5.23\bin
sql/xml query in jsp - JSP-Servlet
sql/xml query in jsp  Sir I am coding in jsp and trying to retrieve xml data from db2 using sql/xml query in jsp but getting no result. When running jsp file in browser the output
Reading a xml file - JSP-Servlet
Reading a xml file  how to read a xml file using jsp and then i have to retrive a data from that file use it in code?  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/parsing-xml.shtml
XML - JSP-Servlet
XML  Hello have a nice time, how to write an web.xml which can access both jsp page and servlet file can you explain with example.. thanking you.   Hi Friend, Do you want the web.xml file? Please clarify
sql/xml query in jsp - JSP-Servlet
sql/xml query in jsp  Sir Here is my code which is not working Testing JSP select id from "SYSTEM..." name:PROFILE columns:id (bigint) and INFO (xml) data stored:id=1 and info=nitin
project in JSP and XML(to store data)
project in JSP and XML(to store data)  I need to complete an assignment in JSP and using XML as Database ,Please help me to complete... of JSP Web Application demonstrating web technology concepts? Create n
How to access the Title tag from xml to jsp
How to access the Title tag from xml to jsp  How to access the Title tag from xml to jsp   Please visit the following link: http... that will read an xml file and display the data into jsp file
JSP and XML .data store nd retrieve
JSP and XML .data store nd retrieve  I have made a form in jsp having... in xml file.How can i store data entered by user in XML file and later retrieve data in another jsp page using retrieve submit button.Please tell step by step
Reading a xml file - JSP-Servlet
Reading a xml file  Thanks for ur answer sir but problem is that i have to do a reading a xml file of a employee record and then i have to use a employee details to send mail to those employees how to do i sir please help me
How to access the following tag from xml to jsp
How to access the following tag from xml to jsp  How can i get the title where cat="1" and "My Title" from XML File?   Please visit the following link: http://www.roseindia.net/jsp/parsing-xml.shtml The above link
Using JSP in pure XML generating conforming XHTML
; Example program to demonstrate using JSP in pure XML generating conforming XHTML This JSP example describes how JSP tags for XML can be used in XML generation...; Some of the important tags used in JSP files in their XML format is given
how to store data in XML file - JSP-Servlet
how to store data in XML file  hi i have to store the data for example user id and password in a xml file the input userid and password will be coming from jsp middle ware servlet how to do that?   Hi friend
XML Transformation in JSP
XML Transformation in JSP  ... illustrate use of XML transformation tag in JSP file. This example performs... into XML-XSL Transform JSP page by transforming and checking the data with "
Produces XML file but format not correct for storing data using JSP and XML
Produces XML file but format not correct for storing data using JSP and XML  hii I have created a project using JSP and XML as database to store data... XML file also(wrong format),shows result in JSP page but server shows
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
JSP Write XML
JSP Write XML     ... dynamic XML using JSP. JSP technology is basically used for building HTML pages... The Tutorial illustrate an elaborate example on JSP Write XML. To understand
Extract xml to store into db - JSP-Servlet
Extract xml to store into db  Hi all, I need to get the data from the xml file and store it onto the database. Is there anyway of doing this? thanks
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: .  i had an error:"XML... into an xml file. i use the jspBean to call the writeXML class. pls help me to solve.../jsp/jdo-mparsing-xml.shtml http://www.roseindia.net/jsp/java-beans.shtml
Reflecting changes in xml files included in jsp page dynamically...
Reflecting changes in xml files included in jsp page dynamically...  ... xml file in my jsp page as:- <%@ include file="Home.xml"%> But when I... not reflect in jsp page, though the xml file has already changed in system...even
Reflecting changes in xml files included in jsp page dynamically...
Reflecting changes in xml files included in jsp page dynamically...  ... xml file in my jsp page as:- <%@ include file="Home.xml"%> But when I... not reflect in jsp page, though the xml file has already changed in system...even
sorting and filtering the displayed table data using jsp and xml
sorting and filtering the displayed table data using jsp and xml  I have created a xml file and a jsp file, which uses DOM parser to display the content of xml file in web page. Now I would like to sort and filter those data
How to extract details from XML? - JSP-Servlet
How to extract details from XML?  I want to extract details from http://service.openkapow.com/palanikumar/airportantigua.rest How can i extract details from this link?Here is my program... Airport
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO SIR, CAN ANYONE HELP ME OUT HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML... EMPLOYEES SHOULD BE SAVED IN XML FILE AND MY SQL DATABSE TABLES AT A TIME, AND ALSO
Display JSP selected listbox and checkbox in xml-please help me
Display JSP selected listbox and checkbox in xml-please help me  Hi, I have three Listbox on my jsp page. I want to do following:ADS_TO_REPLACE_1... jsp. When user select something from 2nd list, third page contains checkbox
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier... the technologies JSP,Servlet and JDBC etc... Thanks
Data needs to be gathered in XML file from the database (MySql) using JSP
in XML file from the database (MySql) using appropriate JSP/Java Bean functions...Data needs to be gathered in XML file from the database (MySql) using JSP  on index.jsp page, where the user will be able to search, with search
How to store data entered by User in JSP page in XML file
How to store data entered by User in JSP page in XML file  How to store data entered by user in JSP page to be saved in XML file.On clicking submit...   JSP store data entered by user into XML file 1)form.jsp: <html>
Display image on JSP page using XML
Display image on JSP page using XML  ... can display a image on JSP page by using XML.  This example will examine how to parse and expose XML information using the JAXP with a JSP page
how to append data to XML file in proper format using JSP
how to append data to XML file in proper format using JSP  hello i was appending my XML file to add more data entered by user in JSP page.But not getting XML file in proper format as XML rules.lease help me to get XML file
Use of Core XML tags in JSP
Use of Core XML tags in JSP   ... use of Core XML tag in JSPADS_TO_REPLACE_1 JSTL (JSP standard tag library) XML.../msg08807.html This example illustrates use of XML core tags into a JSP file
Example of printing Text message passed from XML to JSP
Example of printing Text message passed from XML to JSP... we are going to know how we can pass a text message from XML to JSP.  ... into the jsp page. What we need to learn is to retrieve the data from the XML file
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page  I have made a form in JSP having emp id... by user to be stored in xml file.here you have entered data in JSP file
XML
XML  How i remove a tag from xml and update it in my xml
xml - XML
://www.roseindia.net/xml/ http://www.roseindia.net/jsp/jdo-mparsing-xml.shtml http...xml  define parser and xml,in jaxp api how to up load parsers... then the program contains syntax errors. XML is defined as an extensible
xml
xml  why the content written in xml is more secure
xml
xml  validate student login using xml for library management system
xml
xml  validate student login using xml for library management system
xml
xml  what is name space,xml scema give an example for each   XML Namespaces provide a method to avoid element name conflicts.They are used for providing uniquely named elements and attributes in an XML document
XML
XML  create flat file with 20 records. Read the records using xml parser and show required details
XML
XML  please tell me how i remove one tag out of all similar type of tags in xml
xml
xml  how can i remove white space and next line when i copy stream to xml file
xml
xml  what is xml   Extensible Markup Language (XML... that is both human-readable and machine-readable. It is defined in the XML 1.0... gratis open standards. The design goals of XML emphasize simplicity, generality
XML
XML  Hi...... Please tel me about that Aren't XML, SGML, and HTML all the same thing?ADS_TO_REPLACE_1 Thanks

Ads