首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

JAXB解析xml时忽略命名空间的步骤

2013-03-10 
JAXB解析xml时忽略命名空间的方法public static ConnectivityDeliveryResponse unmarshall(String respons

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 ; }

?

热点排行