There is a code:

public void startElement(String uri, String localName,String qName, Attributes attributes) throws SAXException { System.out.println("Start Element :" + qName); if (qName.equalsIgnoreCase("узел1")) { Узел1 = true; } 

Here I extract the value for this XML document construction:

 <узел1>value</узел1> 

I get this value with the following code:

 public void characters(char ch[], int start, int length) throws SAXException { if (Узел1) { System.out.println("Узел1 : " + new String(ch, start, length)); Узел1 = false; } 

Everything is good and beautiful, but I would like to implement the work with attributes on the following XML document structure:

 <Узел атрибут = "это значение надо достать" атриубт2="и это тоже"/> 

How to implement it?

    1 answer 1

    Here is a fairly simple example of solving your problem: http://examples.javacodegeeks.com/core-java/xml/sax/get-element-attributes-in-sax-xml-parsing/

    • Literally 15 minutes ago I found this example and did it) But thanks anyway, you are helping me the second day! - kxko