Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So basically using the SAX parser is a good choice for you (it is fast, allows you to filter out all the unnecessary data, consumes low memory). When working with SAX for the first time, you may find the following example useful. I do not say the code is perfect (it misses e.g. exception handling, safe stream closing, etc.), but it could be a good start point for you.</p> <pre> <code> import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.List; 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; public class Test { private static final String HTML_INSTRUCTIONS = "html_instructions"; public static void main(String[] args) throws Exception { final List htmlInstructions = new ArrayList(); SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); DefaultHandler dh = new DefaultHandler() { private boolean isHtmlInstructions = false; private StringBuilder sb = new StringBuilder(); @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { super.startElement(uri, localName, name, attributes); if (HTML_INSTRUCTIONS.equals(name)) { isHtmlInstructions = true; } } @Override public void characters(char ch[], int start, int length) throws SAXException { if (isHtmlInstructions) { sb.append(ch, start, length); } } @Override public void endElement(String uri, String localName, String name) throws SAXException { super.endElement(uri, localName, name); if (HTML_INSTRUCTIONS.equals(name)) { htmlInstructions.add(sb.toString()); sb.delete(0, sb.length()); isHtmlInstructions = false; } } }; InputStream is = new FileInputStream("test.xml"); sp.parse(is, dh); for (String htmlInstruction : htmlInstructions) { System.out.println(htmlInstruction); } } } </code> </pre> <p>The output should look like this:</p> <pre> <code> Head &lt;b>east on &lt;b>S Street Viaduct&lt;/b> </code> </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload