我想解组其中包含“&”字符的 xmlString。
XMLInputFactory xif = XmlUtils.newXMLInputFactory();
String test = "<Res>Abc & Def</Res>";
StringReader sr = new StringReader(test);
try {
XMLStreamReader reader = xif.createXMLStreamReader(sr);
JAXBContext jaxbContext = JAXBContext.newInstance(BluelineReprintInvoiceResponseData.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Object o = unmarshaller.unmarshal(reader);
} catch(Exception ex) {
ex.printStackTrace();
}
有没有办法在不使用 replace/replaceAll 替换字符串中的 '&' 字符的情况下解组字符串?