[Solved] How to know what child is belonging to their parent?


You have an XML-file and you want to read it with a Java-program. You could either go through hell and write your own program to read XML-files, or you use already existing packages for that, for example the SAX-library.

To use SAX-parser use these import-statements:

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

You have to create a SAX-parser from a SAXParserFactory. The factory itself is created with a static factory-method.

SAXParserFactory f = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();

You use parser to read the XML-file and give the output to DefaultHandler. Everything is handled by DefaultHandler so there is where your code goes.

Documentation of DefaultHandler

solved How to know what child is belonging to their parent?