Use xml and retrieve the stored data using dom parser

Assignment Help Basic Computer Science
Reference no: EM13166580

project that requires me to use XML and retrieve the stored data using DOM parser. I have it written to the point that it writes regular equations no problem. But I want to include graph using images in the form of JPEG. Is there any way I can store the name of the image in xml and call it using DOM parser? Or do I need to specifiy the path using getAbsolute path? My Dom parser has the format of:

public class RetrieveXML {

/*** Default constructor*/   private String dpath;public RetrieveXML(String path) {dpath = path;}
/*** Function to return question IDs for later output processing.* @param section* @return List of integer values of questions that are of the given difficulty*/public List returnByGraph(String graph){List questionsToReturn = new List();try {DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();DocumentBuilder docBuilder = dBF.newDocumentBuilder();Document database = docBuilder.parse(new File(dpath));NodeList listOfQuestions = database.getElementsByTagName("question");for(int i=0; i<listOfQuestions.getLength(); i++) {Node firstQuestion = listOfQuestions.item(i);Element firstQuestionE = (Element)firstQuestion;NodeList sectionlist = firstQuestionE.getElementsByTagName("graph");Element firstSectionElement = (Element)sectionlist.item(0);NodeList textSectionList = firstSectionElement.getChildNodes();double sectionvalue = Double.valueOf(textSectionList.item(0).getNodeValue().trim());if (sectionvalue == section) {NodeList idlist = firstQuestionE.getElementsByTagName("id");Element firstIDElement = (Element)idlist.item(0);NodeList textIDList = firstIDElement.getChildNodes();String questionID = textIDList.item(0).getNodeValue().trim();questionsToReturn.add(questionID);}}}catch(ParserConfigurationException pce) {pce.printStackTrace();}catch(SAXException se) {se.printStackTrace();}catch(IOException ioe) {ioe.printStackTrace();}return questionsToReturn;}

XML file:

<TestBank>
<question><id>0002</id><subject>Calculus I</subject><section>2.2</section>             <topic>limit</topic><difficulty>3</difficulty>             <latex_instructions>Determine the infinite limit:</latex_instructions><latex_q>\lim_{x \to 2\pi^-} x csc x</latex_q><graph> image.jpeg </graph><jeopardy_q> </jeopardy_q><jeopardy_a> </jeopardy_a><instructions> </instructions></question><TestBank> 

 

Reference no: EM13166580

Questions Cloud

Washing dishes in a three-compartment sink : When washing dishes in a three-compartment sink, the dishwasher finds the chlorine concentration to be 500 ppm. The dishwasher keeps washing. Identify the most likely hazard.
Java program that asks the user for 100 values : Write a Java program that asks the user for 100 values (or generates these randomly) and stores and displays only the distinct values. Hint: use an array to store and display these values.
Social network style : “The biggest payoff of these social network style tools may prove to be better performance by the boss.” State whether or not this statement justifies the time and cost of implementing these systems and provide a rationale.
Translate than c source code : Why does Ada take so much more time to translate than C source code? What phase of the Ada translation takes the longest?
Use xml and retrieve the stored data using dom parser : project that requires me to use XML and retrieve the stored data using DOM parser. I have it written to the point that it writes regular equations no problem. But I want to include graph using images in the form of JPEG.
Important sources of tax revenue : List the federal government's three most important sources of tax revenue. How do these differ from your state government's three most important sources of tax revenue and those of local government? Why do you think that these different government en..
Problem of determining whether a dfa : Consider the problem of determining whether a DFA and a regular expression are equivalent. Express this problem as a language and show that it is decidable.
What is the minimum number of attendants : A nursing home employs attendants who are needed around the clock. Each attendant is paid the same, regardless of when his or her shift begins. Each shift is 8 consecutive hours.
A queue is a first-in, first-out list : A queue is a first-in, first-out list. The queue has two essential operations: enqueue, which appends an entry to the end of the list (called the tail ) and dequeue, which returns and removes the first entry in the list

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Sequence of events necessary to establish communication

Multiple KDC Domains to chain of three KDC. In other words, suppose that Alice wants to talk to Boris through a chain of 3 KDCs. Provide sequence of events necessary to establish communication.

  How many different seven-digit phone numbers can be formed

How many different seven-digit phone numbers (ignoring area code) can be formed? Can city of 2 million people be served by single area code? Describe.

  Rsa protocol to encrypt and decrypt messages

In this problem you are enquired to hand-turn RSA protocol to encrypt and decrypt messages by using rather smaller numbers than are used in practice, so that calculations can be done by hand.

  Reverse a sixteen-bit binary number by lc program

How to reverse a 16-bit binary number by LC-3 program? Program should assume that the word to be reversed is stored in memory location x3100.

  Design two level and-or and not circuit

Design a two level AND , OR ,NOT circuit for the following I/O priority circuit,when the ack input is true ack will be made true for the smallest j for which req is true.

  The sport of gymnastics requires both impressive

The sport of gymnastics requires both impressive physical strength and extensive training for balance. The iron cross is an exercise performed on two suspended rings

  Computing days take for fine to reach d dollars

In the recent court case, a judge cited the city for contempt and ordered fine of $2 for first day. Each subsequent day, till the city followed judge's order, fine was squared.

  Explain one technological device

Explain one technological device in 350 to 700 words. Include the following:When did it come (or will it potentially come) into existence? What scientific or technological reasoning explains how this potential will be (or can be) be reached in t..

  A direct-mapped cache with 8 two-word blocks

Based on the following sequence of word addresses generated by the processor:1, 134, 212, 1, 135, 213, 162, 161, 2, 44, 41, 221a) Given a direct-mapped cache with 8 two-word blocks that is initially empty

  Computer will ever be developed which can think like human

Do you think a computer will ever be developed which can think like human? Write down the ethical implications of creating such a computer?

  Find a regular expression and an finite automata

For the following pair of regular languages, find a regular expression and an Finite Automata that each define L1 ? L2

  Item number in the inventory

Write a console program that will ask the user for an item number in the inventory and display the name of that item. Stay in a loop so that the user may enter the item number multiple times. Use the letter E to exit the application. Show an error me..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd