【发布时间】:2022-01-12 13:33:52
【问题描述】:
我想解组一个包含 '&' 字符的 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 替换字符串中的 '&' 字符的情况下解组字符串?
【问题讨论】:
标签: java xml-parsing unmarshalling xmlstreamreader