Example usage for javax.xml.soap Node getNextSibling

List of usage examples for javax.xml.soap Node getNextSibling

Introduction

In this page you can find the example usage for javax.xml.soap Node getNextSibling.

Prototype

public Node getNextSibling();

Source Link

Document

The node immediately following this node.

Usage

From source file:org.libreplan.importers.TimSoapClient.java

/**
 * Unmarshals the specified paramter <code>soapBody</code> to the specified
 * <code>clazz</code>//  w  ww . j  a v  a 2 s . c  om
 *
 * @param clazz
 *            object to hold unmarashal result
 * @param soapBody
 *            the soap body to be unmarshalled
 * @return the unmarashalled object
 * @throws JAXBException
 *             if unmarshal failed
 */
@SuppressWarnings("unchecked")
private static <T> T unmarshal(Class<T> clazz, SOAPBody soapBody) throws JAXBException {
    JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    Node bindElement = (Node) soapBody.getFirstChild();

    while (bindElement.getNodeType() != Node.ELEMENT_NODE) {
        bindElement = (Node) bindElement.getNextSibling();
    }

    return unmarshaller.unmarshal(bindElement, clazz).getValue();
}