Java HTML/XML - 如何在StAX中的轉(zhuǎn)義字符串
我們想知道如何在StAX中的轉(zhuǎn)義字符串。
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
public class Main {
public static void main(String[] args) throws Exception {
XMLOutputFactory xof = XMLOutputFactory.newFactory();
XMLStreamWriter xsw = xof.createXMLStreamWriter(System.out);
xsw.writeStartDocument();
xsw.writeStartElement("response");
xsw.writeStartElement("message");
xsw.writeCharacters("1 < 2");
xsw.writeEndDocument();
xsw.close();
}
}