I parse xml using jaxb. I want to parse xml successfully also when xml is not valid that have additional tag. Just ignore tag that non-exist in xsd. Is it possible?
I'm assuming you mean that you're talking about well-formed XML, but XML which contains elements that are not defined in the schema?
If so, then JAXB is fine with that. Any elements in the input XML which JAXB does not recognise will simply be ignored.
My code is below. Jaxb parse succesfully till unknown-tag, after first unknown-tag, for all defined tags warning this tag is not-known tag (print "Unexpected element{}..." message)
`Unmarshaller unmarshaller = context.createUnmarshaller(); unmarshaller.setValidating(false); ValidationEventHandler validationHandler = new IwisValidationEventHandler(); unmarshaller.setEventHandler(validationHandler);
public class IwisValidationEventHandler implements ValidationEventHandler { private static Logger logger = Logger.getLogger(IwisValidationEventHandler.class); public boolean handleEvent(ValidationEvent ve) { System.out.println(ve.getMessage); return true; } }`