Im trying to parse the input stream from a zipfile zip entry and trying to create a org.w3c.dom.Document but for some reason im getting a DefferedDocumentImpl back. Im also creating a new org.w3c.dom.Document and this is returning a DocumentImpl. Then using Xpath to select a single node but im getting this error "org.apache.xerces.dom.DocumentImpl incompatible with org.jdom.Element" when Im trying to find my specific node. Ive done some searching but cant seem to find and examples. Anyone know why im not getting my docs created as dom docs? Thanks in advance for the help.
//create a zip file from the crate location
File downloadFile = crate.getLocation();
ZipFile zipFile = new ZipFile(downloadFile);
//put all the contents of the zip file into an enumeration
Enumeration entries = zipFile.entries();
while (entries.hasMoreElements()){
ZipEntry entry = (ZipEntry) entries.nextElement();
String currentEntry = entry.getName();
if (currentEntry.equals("ATTACH 8130-3 XML/signature.xml")){
InputStream zipStream = zipFile.getInputStream(entry);
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
org.w3c.dom.Document doc = (org.w3c.dom.Document)dBuilder.parse(zipStream);
doc.getDocumentElement().normalize();
NodeList certNode = doc.getElementsByTagName("ATA_PartCertificationForm");
int testInt = certNode.getLength();
org.w3c.dom.Document doc2 = (org.w3c.dom.Document) dBuilder.newDocument();
Node parentNode = doc.getParentNode();
Element rootElement = doc2.createElement("CurrentCertificate");
doc2.appendChild(rootElement);
for(int i=0; i<certNode.getLength(); i++){
Node childNode = certNode.item(i);
Element childElement;
childElement = (Element)certNode.item(i);
rootElement.appendChild(doc2.importNode(childNode, true));
String nameString = childNode.getNodeName();
Element block13Element = (Element) XPath.selectSingleNode(doc2, "//Block13M");
System.out.println("tester test");
}
System.out.println("Test break");
}
}