SAXParser Problem, startElement wird nicht ausgeführt

Status
Nicht offen für weitere Antworten.

8bitme

Neues Mitglied
Hi,

ich möchte eine XML-Datei einlesen und habe das Problem das die Methode startElement des DefaultHandlers nicht ausgeführt wird. Die Methoden character und endElement werden ausgeführt.

Ich bin für jede Idee dankbar und bedanke mich schon einmal im vorraus.

Martin

Ich hab folgende XML-Datei:
Code:
<xml>
<Spielinformation>
<dataelem Schiedsrichter="Hilmar B." />
</Spielinformation>

<Skizzen>
</Skizzen>

<Notizen>
<Notiz id="blub007">bluuuuub</Notiz>
</Notizen>

<BewertBogen>
<Kriterium>Stuermerfoul

<Multiplikator>5</Multiplikator>
<Mangelgruppe checked="false">Stuermerfoul mit Ballbesitz
<UFehler checked="true">anrennen, anspringen</UFehler>
<UFehler checked="false">anrennen (nach Anspiel)</UFehler>
</Mangelgruppe>

</Kriterium>

</BewertBogen>

</xml>
und der Handler dazu :
(falls irgendwo klammern etc. fehlen, das könnte daher kommen das ich den code eingekürzt habe ... also eclipse bescheinigt mir fehlerfreiheit ;-) )
Code:
import java.util.Vector;

import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import com.sun.org.apache.xalan.internal.xsltc.runtime.Attributes;

class myHandler extends DefaultHandler{
	
	
	public void startDocument() throws SAXException{
//debug
		  System.out.println("------------>\r\nDocumentStart");
//debug ende	
	}

	public void warning(SAXParseException e) throws SAXException{
		System.out.println("----->Line: "+e.getLineNumber()+ " Col: "+ e.getColumnNumber()+ " Message: "+ e.getLocalizedMessage());
	}
	
		
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

//		debug
		  System.out.println("StartTag: "+qName+ " Stackhoehe: "+ObjStack.size());
//	debug ende

	 }
	 
	 
	 
 public void endElement(String uri, String localName, String qName) throws SAXException{

// debug
    System.out.println("EndTag: "+qName+ " Stackhoehe: "+ObjStack.size());
//debug ende    
    
    
 }
			
 public void characters(char[] ch, int start, int length) throws SAXException{	 
	 //			  	produktiv
			 	   // Content in String
			 	   String Content = new String(ch, start, length).trim();
			 	   

// debug
					  System.out.println("Content: "+Content);
//	debug ende			 	   
			 	   
			}		  		


 
}

und die den handler aufrufende klasse:
Code:
import java.io.IOException;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import com.sun.org.apache.xerces.internal.parsers.SAXParser;




public class XmlDaten {

	private String filename = new String();

	
	private myHandler MyData = new myHandler();
	
	private SAXParserFactory myFactory;
	private javax.xml.parsers.SAXParser myParser;
	

	
	public XmlDaten(String filename) throws ParserConfigurationException, /*SAXException,*/ IOException{
		try {
			 myFactory = SAXParserFactory.newInstance();
			
	        try
	        {
	        	myParser = myFactory.newSAXParser();
	            myParser.parse(filename, MyData);
            
	        }
	        catch (Exception e)
	        {
	            System.err.println("Fehler beim parsen: ");
	            System.err.println(e);
	        }
		}
		finally{}
				
	}

		
}
 
R

Roar

Gast
startElement will org.xml.sax.Attributes, keine com.sun.org.apache.xalan.internal.xsltc.runtime.Attributes
 

8bitme

Neues Mitglied
Hi Roar,
danke für deine verdammt schnelle Antwort!
Du hast keine Ahnung wie sehr Du mir grad den Tag gerettet hast.

VIELEN, VIELE, VIELEN und nochmals VIELEN DANK!!!

LG Martin
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
P SAXParser problem? XML & JSON 2
J SAXParser Klasse XML & JSON 12
M Multithreaded SAXParser XML & JSON 8
L XMLDatei mit SAXParser prüfen XML & JSON 3
mdee SAXParser XML & JSON 2
R SaxParser und Sonderzeichen "&" XML & JSON 3
E Saxparser Exection bei Jasperreports XML & JSON 11
O XPATH Problem - Anfänger XML & JSON 4
so_ein_Komischer Problem mit Clean and Build XML & JSON 1
P JAXB-Problem XML & JSON 1
W Problem mit dem mit XML sortierung XML & JSON 2
S Jaxb Unmarshalling Problem XML & JSON 4
E einfaches Problem XML + XSD + jedit XML & JSON 2
S Xslt Problem XML & JSON 2
B JasperReport Problem in Runtime XML & JSON 2
S Problem with JAXB unmarshalling classes that have the same name in @XmlRootElement XML & JSON 2
R Problem bei: XML und XSL zu HTML XML & JSON 2
M Read / write Problem beim ByteStrom XML & JSON 2
M XML write Problem zweiter Ansatz XML & JSON 3
M XML read Problem XML & JSON 4
M XML write Problem XML & JSON 2
whitenexx Problem beim parsen von Facebook XML XML & JSON 3
M XML Unicode Problem XML & JSON 2
S XJC --> Java-Objects compile Problem XML & JSON 4
F XPath-Problem mit DOM4J XML & JSON 8
B JPA + JAXB Mapping Problem XML & JSON 2
T XPath Problem: finden einer Node nach Attributswert XML & JSON 2
G Problem beim schreiben von XML in eine File XML & JSON 2
S Encoding Problem XML & JSON 7
K JAXB und Maps -> Marshalling-Problem XML & JSON 6
B Problem beim löschen von ChildNodes aus einem XML-DOM XML & JSON 3
E JDOM - Problem beim Zusammenfügen zweier Dateien XML & JSON 2
M JExcelAPI (JXL) Encoding Problem XML & JSON 11
S DOM Parsen Problem mit HTML Sonderzeichen XML & JSON 4
A aus xml --> html Problem XML & JSON 3
Y stax Problem XML & JSON 3
slawaweis Problem mit XSLT (wahrscheinlich ein Bug in Java 6) XML & JSON 16
T Problem beim Parsen von Attribut xmlns="urn:com:test&qu XML & JSON 6
P XPath Problem XML & JSON 2
J Problem beim XML-Lesen XML & JSON 2
M Problem mit FOP in Java Programm XML & JSON 2
S Problem mit XPath XML & JSON 4
J Problem mit compile einer XSD XML & JSON 3
N jdom problem beim lesen von child elementen XML & JSON 5
N problem bei xml lesen mit jdom XML & JSON 2
A XPath Problem XML & JSON 2
W JDOM element ändern funzt nich :( [problem gelöst] XML & JSON 3
G Problem mit XML-Schema Validierung mit Java XML & JSON 12
B jdom: getChildren() problem XML & JSON 4
H XSL-FO Problem mit If XML & JSON 2
loadbrain XPath Problem XML & JSON 2
T addContent / Problem mit Variable XML & JSON 2
F Problem mit JAXB Unmarshaller XML & JSON 2
F JDOM und XPath - Problem mit Namespace ohne Prefix XML & JSON 5
M Java und XSLT: Performanz-Problem XML & JSON 5
X JDOM SAXBuilder Validationschema - Problem XML & JSON 8
G Problem mit getContent XML & JSON 4
K stax problem XML & JSON 2
S Problem mit SAX XML & JSON 6
A Problem mit JasperReport XML & JSON 6
G DOCTYPE Problem beim Transformer/TransformerFactory etc. XML & JSON 13
C XSD Problem XML & JSON 16
R Problem bei Erstellung von XML(JDOM) XML & JSON 3
R Problem mit SAX-Parser characters() XML & JSON 7
M XPath Problem im Zusammenhang mit document() XML & JSON 2
P Problem beim erstellen eines neuen Elements (JDOM) XML & JSON 5
Z Problem mit getNodeValue() und setNodeValue() in DOM XML & JSON 6
H JAXB CUSTOMIZATION PROBLEM XML & JSON 2
M XPATH und RSS (Problem namespaces) XML & JSON 7
S Problem beim Erstellen eines pdfs XML & JSON 3
V Problem mit xsd XML & JSON 2
P XML mit hilfe von JDOM abspeichern macht Problem XML & JSON 6
G Problem mit addContent() XML & JSON 4
B DTD Problem - Reihenfolge der Einträge XML & JSON 2
R Problem beim Auslesen von Attributen XML & JSON 4
K Problem mit ant/java web services XML & JSON 4
K xml Datei mit JDOM erzeugen, Problem Namespaces XML & JSON 1
P Problem mit XML und DOM XML & JSON 2

Ähnliche Java Themen

Neue Themen


Oben