public CreateHealthCheckResult unmarshall(StaxUnmarshallerContext context) throws Exception { CreateHealthCheckResult createHealthCheckResult = new CreateHealthCheckResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; if (context.isStartOfDocument()) { context.setCurrentHeader("Location"); createHealthCheckResult.setLocation(StringStaxUnmarshaller.getInstance().unmarshall(context)); } while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return createHealthCheckResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("HealthCheck", targetDepth)) { createHealthCheckResult.setHealthCheck(HealthCheckStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return createHealthCheckResult; } } } }