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

  Determine total hours committed by employee

Assume the weekly hours for all employees are stored in the two-dimensional array. Each row records the employee's seven-day work hours with seven columns. Determine total hours committed by each employee every week.

  Investigate project management body of knowledge

Investigate Project Management Body of Knowledge (PMBoK). Write a report on one of knowledge areas. Describe the task of understanding potential threats

  Develop timeline on computer using microsoft word

Use Microsoft Word, Excel or PowerPoint to develop timeline on computer. Create your own timeline and take a picture, saving file on computer as .jpg or .gif.

  How many bits are in logical address

Consider a simple paging system with the following parameters: 2^32 bytes of physical memory, page size of 2^10 bytes, and 2^16 pages of logical address space. How many bits are in a logical address?

  Program to compute each semester tuition for each student

write a program to compute each semester the tuition for each student. Studient is taking 12 credit or less, tuition is 675 oer credit if student is taking more than 12 credits the total tuition is 6300.

  Which industrialization essentially made us less independent

Many experts assert which industrialization has essentially made us less independent and more closely related to other people than ever before.

  Function drawlinegraph that generates a line graph

Write a function DrawLineGraph that generates a line graph given an array of x-coordinate values, a second array of corresponding y-coordinate values, and the number of data points.

  Structure stack that represents

Design a structure stack that represents a stack of elements of some arbitrary type. Include the functions: create(returns an empty stack), push(add an element to the top of the stack and return the resulting stack)

  Determine the date in opening of letter

If /home/jenny/draft and /home/alex/letter are links to same file and following sequence of events occurs, what will be date in opening of letter? Alex gives command vim letter.

  Cloud provider secure large amount of capital

Few organizations tend to prefer operating expense models. whether Cloud providers will continue to secure large amount of capital....or will equity firms stop their funding?

  Early proof of concept

Currently our organisation has a sample running application to sell books which has been designed as an early proof of concept. The application can be found in your installation at C:glassfish3glassfishdocsjavaee-tutorialexamplescase-studiesdukes-boo..

  Design static method below to find and return complex number

Given a "Complex" class with all the standard methods for complex numbers, design the static method below to find and return the smallest complex number.

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