code: public static String findTitle(final Document doc) {
          if (doc == null) return null;
  
          // loop through the child nodes until the title element is found
          final NodeList childNodes = doc.getDocumentElement().getChildNodes();
          for (int i = 0; i < childNodes.getLength(); i++) {
              Node node = childNodes.item(i);
  
              // check if the node is the title and if its parent is the document root element
              if (node.getNodeName().equals(TOPIC_ROOT_TITLE_NODE_NAME) && node.getParentNode().equals(doc.getDocumentElement())) {
                  return XMLUtilities.convertNodeToString(node, false);
              }
          }
  
          return null;
      }
docs: Finds the first title element in a DocBook XML file.
  
  @param doc The docbook xml transformed into a DOM Document to find the title from.
  @return The first title found in the xml.