Java XML JAXB Unmarshaller unmarshalDOMElement(byte[] input)

Here you can find the source of unmarshalDOMElement(byte[] input)

Description

unmarshal DOM Element

License

LGPL

Declaration

public static Element unmarshalDOMElement(byte[] input)
            throws SAXException, IOException, ParserConfigurationException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.ByteArrayInputStream;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public class Main {
    public static Element unmarshalDOMElement(String xmlValue)
            throws SAXException, IOException, ParserConfigurationException {

        return unmarshalDOMElement(xmlValue.getBytes());
    }//from www. j  ava2 s .c  om

    public static Element unmarshalDOMElement(byte[] input)
            throws SAXException, IOException, ParserConfigurationException {

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();

        Document doc = db.parse(new ByteArrayInputStream(input));

        return doc.getDocumentElement();
    }
}

Related

  1. unmarshal(String xml, Class c)
  2. unmarshal(String xml, Class clazz)
  3. unmarshal(String xml, Class clazz)
  4. unmarshal(T entity)
  5. unmarshalByContent(Class clazz, String xmlContent)
  6. unmarshalFromReader(Reader reader, Class c)
  7. unmarshalFromString(Class clz, String input)
  8. unmarshalFromXml(Class clazz, String xml)
  9. unmarshalFromXml(final String xml, Class destinationClass)