Code example for DOMSource

Methods: getNode

0
public class SaveReservationExtractor implements SourceExtractor { 
    @Override 
    public Object extractData(Source source) throws IOException, TransformerException {
        SaveReservationResponse reservationResponse = new SaveReservationResponse();
        DOMSource domSource = (DOMSource) source;
        Node node = domSource.getNode();
        Node reserveNode =  node.getFirstChild().getFirstChild().getFirstChild();
        if(reserveNode.getNodeName().equals("Reservation")) {
            String id = reserveNode.getFirstChild().getNodeValue();
            reservationResponse.setId(id);
        } 
        return reservationResponse;
    } 
}