I use DocumentBuilder to parse XML files. However, the project specification requires that lines of text, such as "and <, be returned literally and not decoded as characters ( "and <).
A previous similar question, Read the escaped quote as a hidden quote from xml , got one answer that seems to be specific to Apache, and another that looks just don't do what it says. I would love to be mistaken in both calculations :)
For reference, here is some code:
file = new File(fileName);
DocBderFac = DocumentBuilderFactory.newInstance();
DocBder = DocBderFac.newDocumentBuilder();
doc = DocBder.parse(file);
NodeList textElmntLst = doc.getElementsByTagName(text);
Element textElmnt = (Element) textElmntLst.item(0);
NodeList txts = textElmnt.getChildNodes();
String txt = ((Node) txts.item(0)).getNodeValue();
System.out.println(txt);
I would like println () to create things like
"3>2"
instead
"3>2"
which is happening now. Thank!