how to convert array byte to org.w3c.dom.Document

前端 未结 1 1816
悲哀的现实
悲哀的现实 2020-12-19 13:41

I have a Document (org.w3c.dom.Document), I convert this document to array of byte:

private byte[] obtenerBytesDeDocument(Document documentoXml) throws Excep         


        
1条回答
  •  攒了一身酷
    2020-12-19 14:20

    The following should work.

    private Document obtenerDocumentDeByte(byte[] documentoXml) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.parse(new ByteArrayInputStream(documentoXml));
    }
    

    0 讨论(0)
提交回复
热议问题