[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

parsing xml (SAX)

Posted on 2011-04-18
3
Medium Priority
?
229 Views
Last Modified: 2012-05-11
Hi,
I followed tutorial on http://www.totheriver.com/learn/xml/xmltutorial.html
But Im getting error Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code in line sp.parse("http://localhost:8080/WebTools/keywords/api/user?pass=user", this);

what is wrong with this code?

	private void parseDocument() {

		//get a factory
		SAXParserFactory spf = SAXParserFactory.newInstance();
		try {

			//get a new instance of parser
			SAXParser sp = spf.newSAXParser();

			//parse the file and also register this class for call backs
			sp.parse("http://localhost:8080/WebTools/keywords/api/user?pass=user", this);

		}catch(SAXException se) {
			se.printStackTrace();
		}catch(ParserConfigurationException pce) {
			pce.printStackTrace();
		}
	}

Open in new window

0
Comment
Question by:static86
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 668 total points
ID: 35421365
theres nothing wrong with it that I can see. More likely an issue with your IDE
Try cleaning the project, or running it outside the ide
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 664 total points
ID: 35421419

This code copied from yours worked quite fine for me

public class ParseWithSax extends DefaultHandler {

    public static void main(String [] args){

        new ParseWithSax().parseDocument();
    }
    	private void parseDocument() {

		//get a factory
		SAXParserFactory spf = SAXParserFactory.newInstance();
		try {

			//get a new instance of parser
			SAXParser sp = spf.newSAXParser();
  
            sp.parse("http://www.w3schools.com/xml/note.xml", this);

		}catch(SAXException se) {
			se.printStackTrace();
		}catch(ParserConfigurationException pce) {
			pce.printStackTrace();
		}  catch(Exception exx){
            exx.printStackTrace();
        }
	}
}

Open in new window



Process finished with exit code 0

Open in new window

0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 668 total points
ID: 35422648
See if the following helps:

1. Take the method parseDocument from this page and paste it into Notepad (assuming you're using Windows)
2. Delete the method from your code editor
3. Paste it back in from Notepad

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question