Go to main content

Developing Data Services

Exit Print View

Updated: August 2018

How to Set Up the XML Parser

You have now created the networking and XML generation code for the application. The CrnpClient constructor calls a setupXmlProcessing method. This method creates a DocumentBuilderFactory object and sets various parsing properties on that object. The JAXP documentation describes this method in more detail. See https://docs.oracle.com/javase/9/.

  • Create the Java code that implements the preceding logic.
    private void setupXmlProcessing() throws Exception
    dbf = DocumentBuilderFactory.newInstance();
    // We don't need to bother validating
    // We want to ignore comments and whitespace
    // Coalesce CDATA sections into TEXT nodes.