这是我的程序:
public class XMLTest {
static String XMLdata="<Section DisplayLocation=\"Middle\" TargetLocation=\"ufdLocation0\" TemplateFileName=\"formaol\" TemplateID=\"formaol\" TemplateName=\"Form AOL\" UFDID=\"2a3935c7-105d-470e-b8ab-ad90c8f44880\"><Inputs BusinessNamePP=\"<><>\" Caption=\"\" Description=\"A line must be active on your account for at least 30 days before it can be transferred to a new account.You have <?ufd 'Test'?> days remaining before you can transfer.\" Image1=\"\" Image2=\"\" ImageLabel1=\"\" ImageLabel2=\"\" emailPP=\"<Anji>\" firstNamePP=\"<Jeera>\" lastNamePP=\"<Hellow>\"/></Section>";
public static void main(String args[]){
Document doc = null;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
db = dbf.newDocumentBuilder();
doc = db.parse(new InputSource(new StringReader(XMLdata)));
if (doc != null) {
NodeList nodeList = doc.getElementsByTagName("Inputs");
for(int x=0,size= nodeList.getLength(); x<size; x++) {
System.out.println(nodeList.item(x).getAttributes().getNamedItem("Description").getNodeValue());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
当我运行这个时,我得到的输出为
A line must be active on your account for at least 30 days before it can be transferred to
a new account.You have <?ufd 'Test'?> days remaining before you can transfer.
但我不希望 dom 解析器自动进行这种解码,
我怎样才能防止这种解码发生?
预期输出:
A line must be active on your account for at least 30 days before it can be transferred to
a new account.You have <?ufd 'Test'?> days remaining before you can transfer.
与 XML 中的内容完全相同,但不进行显式转换。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)