0% found this document useful (0 votes)
87 views

PLV Memorial College, Shikargarh Jodhpur: Name Amit Singh Expreriment No Group MSC C.S Date

The document contains details of assignments completed by AMIT SINGH CHOUHAN for his M.Sc. in Computer Science course. It lists 7 assignments on topics related to XML including creating an XML file of a CD catalog, embedding XML in HTML, loading an XML file into a parser, traversing XML nodes, sending queries to a server to receive XML responses, getting the root element of XML using Java, and counting elements in XML files. It records the names, dates and remarks for each completed assignment.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

PLV Memorial College, Shikargarh Jodhpur: Name Amit Singh Expreriment No Group MSC C.S Date

The document contains details of assignments completed by AMIT SINGH CHOUHAN for his M.Sc. in Computer Science course. It lists 7 assignments on topics related to XML including creating an XML file of a CD catalog, embedding XML in HTML, loading an XML file into a parser, traversing XML nodes, sending queries to a server to receive XML responses, getting the root element of XML using Java, and counting elements in XML files. It records the names, dates and remarks for each completed assignment.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

PLV Memorial College, Shikargarh Jodhpur

Name AMIT SINGH Group Msc C.S


1 Create a simple xml file of CD Catalog.

Expreriment No Date .

<CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <TITLE>Greatest Hits</TITLE> <ARTIST>Dolly Parton</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>RCA</COMPANY> <PRICE>9.90</PRICE> <YEAR>1982</YEAR> </CD> <CD> <TITLE>Still got the blues</TITLE> <ARTIST>Gary Moore</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Virgin records</COMPANY> <PRICE>10.20</PRICE> <YEAR>1990</YEAR> </CD> <CD> <TITLE>Eros</TITLE> <ARTIST>Eros Ramazzotti</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>BMG</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD> <TITLE>One night only</TITLE>

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
<ARTIST>Bee Gees</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>10.90</PRICE> <YEAR>1998</YEAR> </CD> <CD> <TITLE>Sylvias Mother</TITLE> <ARTIST>Dr.Hook</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS</COMPANY> <PRICE>8.10</PRICE> <YEAR>1973</YEAR> </CD> <CD> </CATALOG>

Expreriment No Date .

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
2 How to Embedding XML code in HTML File.

Expreriment No Date .

<html> <xml Id = msg> <message> <to> Visitors </to> <from> Author </from> <Subject> XML Code Islands </Subject> <body> In this example, XML code is embedded inside HTML code </body> </message> </xml> </html>

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
3 How to Load XML File into parser <html> <body> <script language="javascript"> var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") document.write ("The first XML element in the file contains: ") document.write (xmlDoc.documentElement.childNodes.item(0).text) </script> </body> </html>

Expreriment No Date .

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
4 Travers XML Files Nodes Note.xml <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <html> <body> <script language="VBScript"> txt="<h1>Traversing the node tree</h1>" document.write(txt) set xmlDoc=CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") for each x in xmlDoc.documentElement.childNodes document.write("<b>" & x.nodename & "</b>") document.write(": ") document.write(x.text) document.write("<br>") next </script> </body> </html>

Expreriment No Date .

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
5

Expreriment No Date .

How to Send a query to server to receive the answer as xml <html> <head> <script language="JavaScript"> function search() { var parser=new ActiveXObject("microsoft.xmldom") parser.async="false" parser.load("send.asp?query=" + query.value) nodes = parser.documentElement.childNodes answer_text.innerHTML=nodes.item(0).text answer_xml.value=parser.xml } </script> </head> <body> <h2> Sending a query to the server and receiving the answer as XML: </h2> <p> <b>Query: </b> <input type="text" name="query" value="Refsnes"> <input type="button" value="Send to Server" onClick="search()"> </p> <p> <b>Answer from server is:</b><br> <span id="answer_text"></span> </p> <p> <b>XML from server is:</b><br> <textarea id="answer_xml" cols="80" lines="10" rows="1">

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
6 How to get Root Element of xml using java Employee-Detail.xml <?xml version = "1.0" ?> <Employee-Detail> <Employee> <Emp_Id> E-001 </Emp_Id> <Emp_Name> Vinod </Emp_Name> <Emp_E-mail> [email protected] </Emp_E-mail> </Employee> <Employee> <Emp_Id> E-002 </Emp_Id> <Emp_Name> Amit </Emp_Name> <Emp_E-mail> [email protected] </Emp_E-mail> </Employee> <Employee> <Emp_Id> E-003 </Emp_Id> <Emp_Name> Deepak </Emp_Name> <Emp_E-mail> [email protected] </Emp_E-mail> </Employee> </Employee-Detail> GetRootNode.java import org.w3c.dom.*; import javax.xml.parsers.*; import java.io.*; public class GetRootNode{ public static void main(String[] args) { try{ BufferedReader bf = new BufferedReader( new InputStreamReader(System.in)); System.out.print("Enter xml file name: "); String str = bf.readLine();

Expreriment No Date .

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S Expreriment No Date .
File file = new File(str); if (file.exists()){ DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = fact.newDocumentBuilder(); Document doc = builder.parse(str); Node node = doc.getDocumentElement(); String root = node.getNodeName(); System.out.println("Root Node: " + root); } else{ System.out.println("File not found!"); } } catch(Exception e){} } }

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S
7 Count the elements in xml files import org.w3c.dom.*; import org.apache.xerces.parsers.DOMParser; import java.io.*; public class CountNodes{ public static void main(String[] args) { try{ BufferedReader bf = new BufferedReader( new InputStreamReader(System.in)); System.out.print("Enter file name: "); String str = bf.readLine(); File file = new File(str); if (file.exists()){ DOMParser parser = new DOMParser(); parser.parse(str); Document doc = parser.getDocument(); System.out.print("Enter element that have to count: "); String ele = bf.readLine(); NodeList list = doc.getElementsByTagName(ele); System.out.println("Number of nodes: " + list.getLength()); } else{ System.out.println("File not found!"); } } catch (Exception e){ e.getMessage(); } } }

Expreriment No Date .

PLV Memorial College, Shikargarh Jodhpur


Name AMIT SINGH Group Msc C.S Expreriment No Date .

PLV Memorial College


Jodhpur

Name: AMIT SINGH CHOUHAN Class:M.Sc.Final(CS) Subject: XML S.No. Assignment Name Date Remarks Sign
1 2 3 4 5 6 7 To create a simple xml file of cd catalog How to embed xml code into html How to load xml filr into paraser Traverse xml file nodes
How to Send a query to server to receive the answer as xml How to get Root Element of xml using java Count the elements in xml files

5/10/09 9/10/09 26/10/09 7/11/09 12/11/09 19/11/09 4/12/09

You might also like