DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
|
|
|
- Kathlyn Molly Fitzgerald
- 10 years ago
- Views:
Transcription
1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING PRACTICAL RECORD CS2358 INTERNET PROGRAMMING LAB NAME : REGISTER NO : SEMESTER :
2 1. CREATING A WEBPAGE USING IMAGE MAP Aim To Create a web page with the following using HTML i) To embed an image map in a web page ii) To fix the hot spots iii) Show all the related information when the hot spots are clicked. Algorithm Step1 :Open a notepad. Step 2:Write the code for imagemap.html. Step 3: Enter a program that includes tags for <MAP> and other tags. Step 4: Insert Hyperlink using <A href>. Step5: Save the file with.html extension. Step6: Run the program in a web browser Step: Display Results. <html> HOME.HTML <head> <title>home - States of India!!!</title> </head> <body bgcolor="gold"> <h1><u><center>republic of India</center></u></h1> <p> </p> <center> India is the Seventh Lagest country in the world by geographical area, the second most populous country with over 1.2 billion people, and the populus democracy in the world. India is a federal constitutional republic with a parliamentry democracy consisting of 28 states and 7 union Terriories. <img align="center" size="100" src="indiamap.jpg" usemap="#india"/> <map name="india"> <area shape="circle" coords="160,340,20" href="andhrapradesh.html">
3 <area shape="circle" coords="120,440,10" href="kerala.html"> <area shape="circle" coords="110,370,20" href=" KARNATAKA.html"> <area shape="circle" coords="140,420,20" href="tamilnadu.html"> </map> </center> <h2> Features</h2> <ul> <li><b>population</b> - 1,028,783,343(2001 census). <li><b>capital</b> - New Delhi <li><b>largest City</b> - Mumbai <li><b>currency</b> - Indian Rupee <li><b>time Format</b> - IST (UTC + 5:30) <li><b>nation Sport</b> - Hockey <li><b>current PM</b> - Manmohan Singh <li><b>current President</b> - Prathiba Patil </li> </ul> <h2> <b>to view details of states please click on the specified area in the map!!!</b> </h2> </body> </html>
4 ANDHRAPRADESH.HTML <html> <head><title>andhra Pradesh - India</title></head> <body bgcolor="tan"> <h1><center>andhra Pradesh</center></h1> <h3>a.p., is a state situated on the southeastern coast of India. It is India's fourth largest state by area and fifth largest by population.</h3> <h3> <ul> <li>districts<i> - 23</i> <li>capital City<i> - Hyderabad</i> <li>largest City<i> - Hyderabad</i> <li>governor<i> - E. S. L. Narasimhan</i> <li>chief Minister<i> - N. Kiran Kumar Reddy</i> <li>population<i> - 78,323,330</i> <li>tourist spots<i> - Tirumala Tirupati, Charminar, Golconda Fort, Chandragiri, Chowmahalla Place, Falaknuma Palace etc.,</i> </ul> <a href="home.html">back</a> </body> </html> KARNATAKA.HTML
5 <html> <head><title>karnataka - India</title></head> <body bgcolor="wheat"> <h1><center>karnataka</center></h1> <h3> <ul> <li>districts<i> - 30</i> <li>capital City<i> - Bangalore</i> <li>largest City<i> - Bangalore</i> <li>governor<i>- Hansraj Bhardwaj</i> <li>chief Minister<i> - D. V. Sadananda Gowda</i> <li>population<i> - 61,130,704</i> <li>tourist spots<i> - Gol Gumbaz, Mysore Palace, Keshava Temple etc.,</i> </ul> </h3> <a href="home.html">back</a> </body> </html> KERALA.HTML <html> <head><title>kerala - India</title></head> <body bgcolor="indianred">
6 <h1><center>kerala</center></h1> <h3> <ul> <li>districts<i> - 14</i> <li>capital City<i> - Thiruvanandapuram</i> <li>largest City<i> - Thiruvanandapuram</i> <li>governor<i> - Hansraj Bhardwaj</i> <li>chief Minister<i> -Oommen Chandy </i> <li>population<i> - 33,387,677</i> <li>tourist spots<i> - Edakkal Caves, Palayur, Kovalam Beach,Munnar, Kochi, Alapuzha etc.,</i> </ul> </h3> <a href="home.html">back</a> </body> </html> TAMILNADU.HTML <html> <head><title>tanil Nadu - India</title></head> <body bgcolor="palegreen"> <h1><center>tamil Nadu</center></h1> <h3>is one of the 28 states of India. Its capital and largest city is Chennai. Tamil Nadu lies in the southernmost part of the Indian Peninsula and is bordered by the States of puducherry, Kerala, Karnataka, Andha Pradesh.
7 </h3> <h3> <ul> <li>districts<i> - 32</i> <li>capital City<i> - Chennai</i> <li>largest City<i> - Chennai</i> <li>governor<i> - Konijeti Rosaiah</i> <li>chief Minister<i> - Jayalalithaa</i> <li>population<i> - 72,138,958</i> <li>tourist spots<i> - Mamallapuran, Ooty, Kodaikanal, Marina, Mudurai Meenakshi Amman Temple, Thanjavur etc.,</i> </ul> <a href="home.html">back</a> </body> </html>
8 SCREEN SHOTS
9
10
11
12 Result:
13 2. CREATION OF HTML PAGE USING CASCADING STYLE SHEET Aim: To create a HTML page using types of Cascading Style Sheet. ALGORITHM Internal CSS: STEP 1: Create a HTML program with <style> tag. STEP 2: Inside the <style> tag, specify the format required for that web page. STEP3 : Run the program with a web browser. External CSS: STEP 4: Open a notepad, type the needed CSS in it and save it with.css extension. STEP5: Refer this.css file in the HTML using the tag <link>. STEP 6: Run the program with a web browser. CSSFILE.HTML <html> <head> <title>flowers</title> <!--Extended Style Sheet --> <link rel="stylesheet" type="text/css" href="newcss.css"> <!-- Embed Style Sheet--> <style type="text/css"> p{ background-color: lightgrey; text-align: justify; margin: 2em 7em; </style> </head>
14 <body id="body"> <h1>flower</h1> <p> <span style="font: 200 x-large fantasy">flower</span> sometimes known as a bloom or blossom, is the reproductive structure found in flowering plants. The flower is God's finest workmanship in the world. It is his finest gift to the mankind. We have seen the flowers of many kinds and to many colors. In India we see the flowers like </p> <!-- Inline Sytle Sheet--> <table style="background-position: center;text-align: center;padding: 3px;"> <tr> <td align="left"> <div class="div"> <ul> <li><a href="">lily</a></li> <li><a href="">lotus</a></li> <li><a href="">rose</a></li> <li><a href="">jasmine</a></li> </ul> </div> </td> </tr>
15 </table> </body> </html> CSS.CSS h1,h2{ text-decoration: underline; font-style: italic; text-align: center; #body{ background-color: tan; border: red dotted; text-align: center;.div{ border: peru solid ; *{ letter-spacing: 1px; a:link{ color: black;
16 a:visited{ color: yellow; a:hover{ color: green; a:active{ color: blue; ul li{ font-size: small; OUTPUT SCREEN SHOT
17 RESULT:
18 AIM 3. WEB FORM VALIDATION USING DHTML To write a java script program that performs form validation. ALGORITHM: STEP 1: Start the program, STEP 2: Create a Form using form elements, STEP 3: Write a script program for validate the form using javascript, STEP 4: Save the file with extension html. STEP 5: Execute the page by opening html file from any browser. STEP 6: Stop the program. STUDENTVALIDATION.HTML <html> <head> <title>cgpa CALCULATION</title> <script type="text/javascript"> function mark() { var name=document.getelementbyid('name'); var regno=document.getelementbyid('regno'); var dept=document.getelementbyid('dept'); var sem1=document.getelementbyid('sem1'); var sem2=document.getelementbyid('sem2'); var sem3=document.getelementbyid('sem3'); var sem4=document.getelementbyid('sem4'); var sem5=document.getelementbyid('sem5'); var sem6=document.getelementbyid('sem6'); var sem7=document.getelementbyid('sem7');
19 var sem8=document.getelementbyid('sem8'); var cgpa=document.getelementbyid('cgpa'); var dest=document.getelementbyid('dest'); if(name.value == 0 ){alert("pls enter the name");return false; if(regno.value == 0 ){alert("pls enter the register number");return false; if(dept.value == 0 ){alert("pls enter the department");return false; if(sem1.value == 0 ){alert("pls enter semester 1 gpa");return false; if(sem1.value > 10 ){alert("pls enter semester 1 gpa between 1-10");return false; if(sem2.value == 0 ){alert("pls enter semester 2 gpa");return false; if(sem2.value > 10 ){alert("pls enter semester 2 gpa between 1-10");return false; if(sem3.value == 0 ){alert("pls enter semester 3 gpa");return false; if(sem3.value > 10 ){alert("pls enter semester 3 gpa between 1-10");return false; if(sem4.value == 0 ){alert("pls enter semester 4 gpa");return false; if(sem4.value > 10 ){alert("pls enter semester 4 gpa between 1-10");return false; if(sem5.value == 0 ){alert("pls enter semester 5 gpa");return false; if(sem5.value > 10 ){alert("pls enter semester 5 gpa between 1-10");return false; if(sem6.value == 0 ){alert("pls enter semester 6 gpa");return false; if(sem6.value > 10 ){alert("pls enter semester 6 gpa between 1-10");return false; if(sem7.value == 0 ){alert("pls enter semester 7 gpa");return false; if(sem7.value > 10 ){alert("pls enter semester 7 gpa between 1-10");return false; if(sem8.value == 0 ){alert("pls enter semester 8 gpa");return false; if(sem8.value > 10 ){alert("pls enter semester 8 gpa between 1-10");return false; cgpa.value=parseint(sem1.value)+parseint(sem2.value)+ parseint(sem3.value)+parseint(sem4.value)+parseint(sem5.value)+ parseint(sem6.value)+parseint(sem7.value)+parseint(sem8.value);
20 var result=cgpa.value/8 if(result >= 7.5){dest.value="First Class"; if(result < 7.5){dest.value="Second Class"; if(result < 5){dest.value="Third Class"; </script> </head> <body bgcolor="pink" align="center"> <form> <h2><center><u>student CGPA VALIDATION</u></center></h2> <br/> <table align="center"> <tr><td>student Name</td> <td><input type="text" id="name" /></td></tr> <tr><td>register No:</td> <td><input type="text" id="regno"/></td></tr> <tr><td>department</td> <td><input type="text" id="dept"/></td></tr> <tr><td>semester 1</td> <td><input type="text" id="sem1"/></td></tr> <tr><td>semester 2</td> <td><input type="text" id="sem2"/></td></tr> <tr><td>semester 3</td> <td><input type="text" id="sem3"/></td></tr> <tr><td>semester 4</td>
21 <td><input type="text" id="sem4"/></td></tr> <tr><td>semester 5</td> <td><input type="text" id="sem5"/></td></tr> <tr><td>semester 6</td> <td><input type="text" id="sem6"/></td></tr> <tr><td>semester 7</td> <td><input type="text" id="sem7"/></td></tr> <tr><td>semester 8</td> <td><input type="text" id="sem8"/></td></tr> <tr><td>cgpa</td> <td><input type="text" id="cgpa"/></td></tr> <tr><td>destinction</td> <td><input type="text" id="dest"/></td></tr> </table> <br/> <center> <input type="button" value="calculate" onclick="mark();"/> <input type="reset" size="25" value="reset"/> </center> </form> </body> </html> OUTPUT
22 SAMPLE SCREEN SHOT RESULT:
23 4.CREATING A COLOUR PALETTE USING JAVA AIM: To Write a Program in JAVA to create applets incorporating the following features. 1. Create a color palette with matrix of buttons 2. Set background and foreground control text area by selecting a color from color palatte. 3. To set background images. ALGORITHM: STEP 1: Start the program, STEP 2: Write a program for applet using java, STEP 3: Save the applet program with extension.java, STEP 4: Compile that program by javac command. STEP 5: Run the applet by entering appletviewer command. STEP 6: Stop the program. AppletClass.java import java.awt.*; import java.awt.event.*; import java.applet.*; public class AppletClass extends Applet implements ItemListener { int curcolor = 6; int flag = 1; String text = "Click any of the Button"; Button buttons[] = new Button[6]; String colors[] = {"Red", "Blue", "Green", "Yellow", "Magenta", "pink"; Image img1; CheckboxGroup cbg = new CheckboxGroup(); Checkbox box1 = new Checkbox("Background Color", cbg, true); Checkbox box2 = new Checkbox("Text Color", cbg, false);
24 Checkbox box3 = new Checkbox("Loading Image ", cbg, false); public void init() { for (int i = 0; i < 6; i++) { buttons[i] = new Button(" "); add(buttons[i]); buttons[0].setbackground(color.red); buttons[1].setbackground(color.blue); buttons[2].setbackground(color.green); buttons[3].setbackground(color.yellow); buttons[4].setbackground(color.magenta); buttons[5].setbackground(color.pink); add(box1); add(box2); add(box3); box1.additemlistener(this); box2.additemlistener(this); box3.additemlistener(this); public void itemstatechanged(itemevent ev) { if (box1.getstate() == true) { flag = 1; else if (box2.getstate() == true) { text = "Default color is black"; flag = 2;
25 else if (box3.getstate() == true) { img1 = getimage(getdocumentbase(), "sample.gif"); flag = 3; repaint(); public void paint(graphics g) { if (flag == 2) { g.drawstring(text, 30, 100); switch (curcolor) { case 0: g.setcolor(color.red); break; case 1: g.setcolor(color.blue); case 2: g.setcolor(color.green); case 3: g.setcolor(color.yellow); case 4: g.setcolor(color.magenta); break; break; break; break; case 5: g.setcolor(color.pink); break; case 6: g.setcolor(color.black); break; g.drawstring(text, 30, 100); else if (flag == 1) { g.drawstring(text, 30, 100); switch (curcolor) { case 0: setbackground(color.red); case 1: setbackground(color.blue); break; break; case 2: setbackground(color.green); break;
26 case 3: setbackground(color.yellow); break; case 4: setbackground(color.magenta); break; case 5: setbackground(color.pink); case 6: setbackground(color.white); break; break; else if (flag == 3) { g.drawimage(img1, 200, 300, this); public boolean action(event e, Object o) { for (int i = 0; i < 6; i++) { if (e.target == buttons[i]) { curcolor = i; text = "You have Chosen" + colors[i]; repaint(); return true; return false; APPLET.HTML <applet code="appletclass.class" width="100%" height="100%"> </applet>
27 OUTPUT : SCREEN SHOT:1 SCREEN SHOT: 2
28 RESULT:
29 AIM: 5.INVOKING SERVLETS FROM HTML FORM To write a program to invoke Servlet from HTML form. ALGORITHM STEP1: Create a HTML page including some form elements. STEP2: Inside the <form> tag, for the action attribute specify the full path name of the File. STEP3: Create a.java file that imports javax.http.servlet.*; STEP4: Set classpath where servlet-api.jar file resides. STEP5: Compile the servlet program using javac programname.java STEP6: Place the class file \Tomcat 5.5\webapps\Examples\WEB-INF\classes\folder. STEP7: Define the dopost function to process the data obtained from the HTML file. STEP8: Modify the web.xml file using your servletclassname. STEP9: Invoke the class file using from your browser Postparam.java import java.io.*; import java.util.*; import javax.servlet.*; public class postparam extends GenericServlet { public void service(servletrequest request,servletresponse response)throws ServletException,IOException { PrintWriter pw=response.getwriter(); Enumeration e=request.getparameternames(); while(e.hasmoreelements())
30 { String pname=(string)e.nextelement(); pw.print(pname+"="); String pvalue=request.getparameter(pname); pw.println(pvalue); pw.close(); Postparam.html <html> <body> <center> <form name="postparam" method=post action=" <table> <tr> <td><b>employee</b></td> <td><input type="textbox" name="ename" size="25" value=""></td> </tr> <tr> <td><b>phone</b></td>
31 <td><input type="textbox"name="phoneno" size="25" value=""></td> </tr> </table> <input type="submit" value="submit"> </body> </html> XML CODE: //Include the code in Web.xml document// <servlet> <servlet-name>postparam</servlet-name> <servlet-class>postparam</servlet-class> </servlet> <servlet-mapping> <servlet-name>postparam</servlet-name> <url-pattern>/postparam</url-pattern> </servlet-mapping>
32 OUTPUT SCREEN SHOTS:
33 RESULT:
34 6.ONLINE EXAMINATION USING JSP AND DATABASE AIM: To write an online Examination using JSP with three tier architecture ALGORITHM: STEP 1: Create a user interface form for getting Seat number and Name STEP2: Create jsp file which calculates the total marks on the server STEP3: Place the jsp file \Tomcat 5.5\webapps\Examples\WEB-INF\jsp\ folder. STEP4: Create a data base to store the existing user details. If a new login has to be created, then display the corresponding page. STEP5: Create a table in MS ACCESS or ORACLE that contains three fields. STEP6: Create a DSN to map the Microsoft Access Driver using ODBC in Administrative Tools. STEP7: Import java.sql.* in the java program to execute the SQL queries. STEP8: Load the database driver by using Class.forName(). STEP9: Create a Connection and Statement Object. STEP10: Establish a Database Connection with DSN using DriverManager.getConnection( ). STEP11: Execute the query using executequery() and that gets stored in a Resultset. STEP12: Until there are records in table specified get the fields in each record one by one and display onto the screen. STEP13: Close the Statement and Connection Object. STEP 14: DIsplay the results Home.html <html> <head> <title>online Examination</title>
35 </head> <body bgcolor=lightgreen> <center> <h1>online Examination</h1> </center> <form action=" method=post name="f1"> <table> <tr> <td><h3>seat Number:</h3></td> <td><input type="text" name="seatno"></td> </tr> <tr> <td><h3>name:</h3></td> <td><input type="text" name="name" size="50"></td> </tr> <br/> <tr> <td><b>total Marks:10(Each question carries equal marks) </b></td> <td></td><td></td><td></td><td><b>time: 15 Min.</b></td> </tr> </table> <br/> <b>1. Apache is an open source web server</b><br/> <input type="radio" name="group1" value="true">true <input type="radio" name="group1" value="false">false
36 <br/> <b>2. In Modern PC there is no cache memory.</b><br/> <input type="radio" name="group2" value="true">true <input type="radio" name="group2" value="false">false <br/> <b>3. Tim-Berner Lee is the originator of Java.</b><br/> <input type="radio" name="group3" value="true">true <input type="radio" name="group3" value="false">false <br/> <b>4.jpg is not a video file extension.</b><br/> <input type="radio" name="group4" value="true">true <input type="radio" name="group4" value="false">false <br/> <b>5. HTTP is a statefull protocol</b><br/> <input type="radio" name="group5" value="true">true <input type="radio" name="group5" value="false">false <br/> <center> <input type = "submit" value="submit"> <input type = "reset" value="clear"><br><br> </center> </form> </body> </html>
37 exam.jsp page language="java" contenttype="text/html"%> page import="java.sql.*"%> page import="java.util.*"%> page import="java.io.*"%> <% int a1=0,a2=0,a3=0,a4=0,a5=0; Connection conn=null; ResultSet rs=null; Statement stmt=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:s1"; conn=drivermanager.getconnection(url,"",""); String myquery; out.write("connected with Database..."); String seatno=request.getparameter("seatno"); String name=request.getparameter("name"); String ans1=request.getparameter("group1"); if(request.getparameter("group1")!=null){ if(ans1.equals("true")) a1=1; else a1=0;
38 String ans2=request.getparameter("group2"); if(request.getparameter("group2")!=null){ if(ans2.equals("true")) a2=0; else a2=1; String ans3=request.getparameter("group3"); if(request.getparameter("group3")!=null){ if(ans3.equals("true")) a3=0; else a3=1; String ans4=request.getparameter("group4"); if(request.getparameter("group4")!=null){ if(ans4.equals("true")) a4=1; else a4=0; String ans5=request.getparameter("group5"); if(request.getparameter("group5")!=null){ if(ans5.equals("true")) a5=0;
39 else a5=1; int tot=a1+a2+a3+a4+a5; if(seatno!=""){ stmt=conn.createstatement(); myquery="insert INTO STUDENTTABLE VALUES('"+seatno+"','"+name+"',"+tot+")"; stmt.executeupdate(myquery); stmt.close(); stmt=conn.createstatement(); myquery="select * from StudentTable"; rs=stmt.executequery(myquery); %> <html> <head> <title>online Examination</title> </head> <body bgcolor="pink"> <br/><br/> <center> <h1>student Database</h1> <br/> <table border="1" cellspacing="0" cellpadding="0"> <tr> <td><b>seat No</b></td> <td><b>name</b></td>
40 <td><b>mark</b></td> </tr> <% while(rs.next()) { out.println("<tr>"); out.println("<td>"+rs.getstring(1)+"</td>"); out.println("<td>"+rs.getstring(2)+"</td>"); out.println("<td>"+rs.getstring(3)+"</td>"); out.println("</tr>"); rs.close(); stmt.close(); conn.close(); %> </table> <br/><br/> <h1>thanks!...</h1> </center> </body> </html>
41 OUTPUT:
42 Result:
43 Aim: Algorithm: 7. PROGRAMS USING XML SCHEMA XSLT/XSL Programs using XML-Schema-XSLT/XSL Step 1: Start the Program Step 2: Create a root process for food Step 3: Create a style for XSLT with focus on each item Step 4: Output the items Step 5: Stop STRUCTURE.XML <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="stock.xsl"?> <breakfast_menu> <food> <name>apple</name> <price>$4.56</price> <description>good energy</description> <calories>650</calories> </food> <food> <name>strawberry</name> <price>$56.7</price> <description>a good ice cream</description> <calories>450</calories> </food> <food>
44 <name>chapathy</name> <price>$5.89</price> <description>morning meal</description> <calories>780</calories> </food> <food> <name>bread</name> <price>$6.78</price> <description>with jam and butter</description> <calories>670</calories> </food> </breakfast_menu> STOCK.XSL <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl=" <xsl:template match="/"> <html> <body bgcolor="tomato"> <h2><center>food STRUCTURE</center></h2> <table border="1" align="center"> <tr bgcolor="silver"> <th>name</th> <th>price</th>
45 <th>description</th> <th>calories</th> </tr> <xsl:for-each select="breakfast_menu/food"> <tr bgcolor="tan"> <td><xsl:value-of select="name"/></td> <td><xsl:value-of select="price"/></td> <td><xsl:value-of select="description"/></td> <td><xsl:value-of select="calories"/></td> </tr> </xsl:for-each> </table></body> </html> </xsl:template> </xsl:stylesheet>
46 OUTPUT : SCREEN SHOT Result:
47 8. PARSING XML DOCUMENT USING DOMPARSER AIM: Write a program using DOM to display the items of XML document ALGORITHM: STEP1: Start the program, STEP2: Write a program in html and save it as filename.html STEP3: Write a xml program and save it with extension filename.xml STEP4: Get a list of simple elements from the DOM. At the end iterate through the list and print the name to verify we parsed it right. STEP5: Load the html program in web browser STEP6: Display the results DOM.xml <?xml version="1.0"?> <simple> <name>web</name> <name>tech</name> </simple> DOM DEMO.html <html> <head> <title>dom DEMO</title> <script lang="javascript"> var XMLDocument =new ActiveXObject("Microsoft.XMLDOM"); XMLDocument.async=false; XMLDocument.load("domnodelist.xml");
48 document.write("xml doc is loaded"); var nodelist; nodelist=xmldocument.getelementsbytagname("name"); alert(nodelist.item(0).firstchild.nodevalue); </script> </head> <body/> </html>
49 OUTPUT : Result:
50 9. PARSING XML DOCUMENT USING SAX PARSERS AIM: Write a program to display the elements of a XML document using SAX ALGORITHM: STEP 1: Start the program, STEP 2: Write a program in java and save it as filename.java STEP 3: Write a xml program and save it with extension filename.xml STEP 4: Compile and Run the java program, STEP 5: Enter the xml file name into the command prompt window. STEP 6: Stop the program. parsingsaxdemo.java import java.io.*; import javax.xml.parsers.*; import org.xml.sax.*; import org.xml.sax.helpers.*; public class parsingsaxdemo { public static void main(string []ar) throws IOException{ System.out.println("Enter the name of Xml document"); BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String file_name=input.readline(); File fp=new File(file_name); if(fp.exists()){ try{ SAXParserFactory parserfact=saxparserfactory.newinstance(); SAXParser parser=parserfact.newsaxparser(); System.out.println("XML Element from the file "+file_name+" are...");
51 DefaultHandler handler=new DefaultHandler(){ public void startelement(string wi,string localname,string element,attributes attr) throws SAXException {System.out.println("\t"+element); ; parser.parse(file_name,handler); catch(exception e){e.printstacktrace(); else System.out.println("\n file is not present"); DOM.XML <?xml version="1.0"?> <simple> <name>web</name> <name>tech</name> </simple> OUTPUT:
52
