Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Interview-Questions parsing xml file in jsp

Have Programming Question? Ask it here!
 
 
 


Java Coder
parsing xml file in jsp
2 Answer(s)      2 years and 11 months ago
Posted in : JSP-Interview Questions


example that pars XML file in JSP


Advertisement
View Answers

August 24, 2011 at 12:08 PM


<%@page import="org.w3c.dom.*, javax.xml.parsers.*" %>
<%
  DocumentBuilderFactory docFactory = 
  DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
  Document doc = docBuilder.parse("C:/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'>Employees of Roseindia</font></h2>
  <table border="2">
  <tr>
  <th>Name of Employee</th>
  <th>Address</th>
  </tr>
  <%
  Element  element = doc.getDocumentElement(); 
  NodeList personNodes = element.getChildNodes(); 
  for (int i=0; i<personNodes.getLength(); i++){
  Node emp = personNodes.item(i);
  if (isTextNode(emp))
  continue;
  NodeList nl = emp.getChildNodes(); 
  %>
  <tr>
  <%
  for (int j=0; j<nl.getLength(); j++ ){
  Node node = nl.item(j);
  if ( isTextNode(node)) 
  continue;
  %>
  <td><%= node.getFirstChild().getNodeValue() %></td>
  <%
  } 
  %>
  </tr>
  <%
  }
  %>
  </table>
  </body>
</html>


August 24, 2011 at 12:09 PM


Here is the roseindia.xml:

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

  <employee>
    <name>A</name>
    <address>Delhi</address>
  </employee>

  <employee>
    <name>B</name>
    <address>Delhi</address>
  </employee>

  <employee>
    <name>C</name>
    <address>Delhi</address>
  </employee>

  <employee>
    <name>D</name>
   <address>Delhi</address>
  </employee>

  </roseindia>


Related Tutorials/Questions & Answers:
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
parsing xml file using java code
parsing xml file using java code  parsing a xml file using java code
Advertisements
parsing XML file to get java object - XML
parsing XML file to get java object  Hello, I'm facing a problem in parsing XML file to get the java object. I've tried to retrieve data from XML file using SAX parser. my XML file structure is the following
parsing word xml file using SAX parser - XML
parsing word xml file using SAX parser  i am parsing word 2003's XML file using SAX.here my question is,i want to write some tag elements which... this xml file and write that xml part into file? can somebody
xml parsing - XML
how can i do this?   Hi friend, Parsing The XML File using DOM parser in JSP visit to : http://www.roseindia.net/jsp/parsing-xml.shtml...xml parsing  Hi i want to parse the xml document which contains US en
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: .  i had an error:"XML Parsing Error: mismatched tag. Expected: ." when uploading and writing them into an xml file. i use the jspBean to call the writeXML class. pls help me to solve
Xml parsing
Xml parsing  Hi..i tried the above code but I unable to know where can i place the xml file
xml parsing
xml parsing  my task is when i wll give java file to a program that program interpret that file separate each and every keywords and indentifiers and return the csv file that contains count of used keywords and idenfiers by using
XML parsing to Mysql database
XML parsing to Mysql database  Can someone please post the code for parsing an XML file into Mysql database using SAX
xml document parsing
xml document parsing   Hi Guys, Xml document has been inserted into the database,how do i parse the xml document stored in database,so that xml document can be retrieved on to JSP file using jdbc/odbc connection. Please help me
parsing xml with jquery
parsing xml with jquery  Please explain how to parse a xml file into jquery. Thanks
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
Parsing The XML File Using JDOM Parser in JSP
Parsing The XML File Using JDOM Parser in JSP... native parser. XML parsing produces an xml parse tree from an XML document. Using... with JDOM parser to parse the xml document. JDOM can read existing XML documents
parsing xml using sax
parsing xml using sax  how to get values if the root elements are same and their attributes are different
XML parsing using Java - XML
XML parsing using Java  I'm trying to parse a big XML file in JAVA. The goal is like i will take console input from user until "Coverage" in element "MIRate"(THE XML code is below).once he enters coverage rate I need
Handling Errors While Parsing an XML File
Handling Errors While Parsing an XML File   ... parsing an XML document. JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used
java with xml parsing - Java Beginners
java with xml parsing  Hi, I need the sample code for parsing complex data xml file with java code. Example product,category,subcategory these type of xml files and parse using java. Please send the code immediately its very
java with xml parsing - Java Beginners
java with xml parsing  Hi, I need the sample code for parsing complex data xml file with java code. Example product,category,subcategory... urgent. this is my xml file.... QWZ5671
Problem facing in SAX Parsing - XML
of all remove & sign from your xml file,it contradicts.And then try...Problem facing in SAX Parsing  I have facing the issue in SAX Parsing like i have got the xml and the xml structure is like below
write xml file with jsp useBean - JSP-Servlet
write xml file with jsp useBean  how to write into xml files with jsp... an org.w3c.dom.Document from XML. Save the xml file at bin file of C:\apache-tomat-5.5.23\bin... allows our application to obtain a Java XML parser. DocumentBuilderFactory
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
Truncating issue while parsing XML with SAX Parser.
Truncating issue while parsing XML with SAX Parser.  I am Parsing one xml file and after parsing I have to enter the data into the database using hibernate. The problem is while parsing some elements, its not getting the complete
problems in parsing the xml with the special characters
problems in parsing the xml with the special characters  Hi, I have a problem, in while parsing the xml with special characters apstrophe('). I am... parse this string in xml path. i am not able to fetch the adam's string in the xml
Problem facing in SAX Parsing - XML
Problem facing in SAX Parsing  I have facing the issue in SAX Parsing like i have got the xml and the xml structure is like below... 0668420957700159USD you can find the above xml
Parsing XML using Document Builder factory - XML
Parsing XML using Document Builder factory  Hi , I am new to XML . I am trying to parse a XML file while is : For this i am using Document... java.io import File from java.io import StringReader from org.xml.sax
Ignoring Comments While Parsing an XML File
Ignoring Comments While Parsing an XML File   ... in an XML File. JAXP is an interface which provides parsing of xml documents. Here... it from the File. Xml code for the program generated
XML Parsing from php web server in J2ME
XML Parsing from php web server in J2ME  Hello Team, You gave some tips for XML parsing in java, i need some additional tips for xml parsing from php web server in j2me... Thanks and Regards Alagu
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 Parsing Using Sax Parser in J2ME for serverside
XML Parsing Using Sax Parser in J2ME for serverside  Hai team, i have doubt in Parsing using sax parser in serverside plz help me for xml parsing in j2me using sax parser on server side thanks in advance... regards Selva
complex xml parsing and storing in database - XML
complex xml parsing and storing in database  Hi Experts ,i want to parse my xml document and store it in mysql database. This is my code. How to parse this complex data. EDI_DC40 800 0000000000557748
XML Parsing Using Sax Parser in J2ME
XML Parsing Using Sax Parser in J2ME  Hai team, I hope you, You should help me, I have trouble in Xml parsing... I have decoded value, what... to do xml parsing help me for that... Regards Alagu
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 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
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
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
Question about parsing XML document with DOM in JAVA.
Question about parsing XML document with DOM in JAVA.  Hi, I need to parse a XML file witch has info about classes. So i have for each class to have... it with multiple for loops, one iside the other but it doesnt work. My XML is this below
Parsing repeatitive xml elements using SAX Parser - XML
Parsing repeatitive xml elements using SAX Parser  Hi, I'm using SAX Parser to read an XML file. My XML file contains repeatitive tags. I'm able to retrieve all the values from the xml file. However, for repeatitive tags
How to implement xml parsing in iphone ? -RV
How to implement xml parsing in iphone ? -RV  In .h file @interface RootViewController : UITableViewController<NSXMLParserDelegate>...; In .m file @implementation RootViewController @synthesize item,title
Creating XMl file - XML
Creating XMl file   I went on this page: http://www.roseindia.net/xml/dom/createblankdomdocument.shtml and it shows me how to create an XML file, however there is something I don't understand. I have to create an XML file
Parsing The XML File using DOM parser in JSP
Parsing The XML File using DOM parser in JSP... provides actions for parsing an XML document. This example helps you to parsing the xml page in jsp. 'parsingxml.jsp' uses 'roseindia.xml' file and display its
Exception during parsing a parameter from the form in JSP
Exception during parsing a parameter from the form in JSP  Exception during parsing params from a form? I get parameters from a html form. I parse the integer one in the JSP file, but I get exception. Is there anyway I can get
xml in JSP - JSP-Servlet
========================= parsingxml.jsp Parsing of xml using DOM Parser...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
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?
HOW TO STORE MULTIPLE EMPLOYEE DETAILS TO XML FILE USING JSP?  HELLO... EMPLOYEES SHOULD BE SAVED IN XML FILE AND MY SQL DATABSE TABLES AT A TIME, AND ALSO HELP ME OUT WITH HOW TO VIEW THE STORED DATA IN XML FILE USING EMPNAME. PLEASE
xml file display - XML
xml file display   - - - - ADL SCORM CAM 1.3 - - session3 - Online Instructional Strategies that Affect Learner... code to display the above xml file in tree structure where
reached end of file while parsing and while expected
reached end of file while parsing and while expected  import java.io.*; public class temperature{ public static void main(String []args)throws IOException{ BufferedReader steffi = new BufferedReader (new
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
Sorting Xml file - XML
Sorting Xml file  I have an xml file like this: Smith USA... sort my xml file. Here is my xslt..., my ouput file will be like this: Amy AUC Bob USA John UK
How to store data entered by User in JSP page in XML file
  JSP store data entered by user into XML file 1)form.jsp: <html>...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
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
splitting large xml file. - XML
splitting large xml file.  Hi, I have a large xml file(1G) and a schema (XSD) i need to split this xml to small xml files (~20M) that will be valid by the schema
 

 

 

DMCA.com