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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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