JAXB解析xml时忽略命名空间的方法
public static ConnectivityDeliveryResponse unmarshall(String response) throws JAXBException, ParserConfigurationException, SAXException { if(txLogger.isDebugEnabled()) { txLogger.debug(response); } JAXBContext jaxbContext = JAXBContext.newInstance(CONNECTIVITY_PACKAGE); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); StringReader reader = new StringReader(response); SAXParserFactory sax = SAXParserFactory.newInstance(); sax.setNamespaceAware(false); XMLReader xmlReader = sax.newSAXParser().getXMLReader(); Source source = new SAXSource(xmlReader, new InputSource(reader)); ConnectivityDeliveryResponse reponse = (ConnectivityDeliveryResponse)unmarshaller.unmarshal(source); return reponse ; }
?