我在我的XML中以“印地语”语言插入字符,这些字符正在被解析并最终显示为“?”代替
我在我的java程序中解析XML但是hindi字符被替换为?。
我的数据库中的其他印地语字符正在正确显示
XML示例:
<?xml version="1.0" ecoding="UTF-8"?>
<attributexml version=""><attribute cat_id="127"><key>ATTRIB_Courses_Offered</key><value>व्यापार लेखा में कैरियर, प्रोग्रामिंग , सॉफ्टवेयर</value></attribute><attribute cat_id="127"><key>ATTRIB_Training_for_individuals</key><value>Yes</value></attribute></attributexml>
以下是解析我的XML的代码:
Map<String, CategoryBeanSpecific> keyValuePair = new HashMap<String, CategoryBeanSpecific>();
Map<String, CategoryBean> attributesMapping = ListingAttributesHelper.getAttributesMapping();
Map<String, String> visitingMap = new HashMap<String, String>();
String attribTobeSingle = CafeConfigInitializer.getInstance().getConfig()
.getAsString("CAFE", "ATTRIBUTES_TO_BE_SINGLE");
String removeKey = null;
try {
if (attrib == null || attrib.length() == 0) {
return keyValuePair;
}
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(new ByteArrayInputStream(attrib.getBytes()));
NodeList attrNodes = doc.getElementsByTagName(Constants.ATTRIBUTE_XML_OBJ);
for (int i = 0; i < attrNodes.getLength(); i++) {
int catId = listingCatId;
if (attrNodes.item(i).hasAttributes()) {
try {
catId = Integer.parseInt(attrNodes.item(i).getAttributes().getNamedItem("cat_id")
.getTextContent());
} catch (Exception exception) {
logger.error(exception);
}
}
NodeList children = attrNodes.item(i).getChildNodes();
List<String> values = new ArrayList<String>();
for (int childIndex = 0; childIndex < children.getLength(); childIndex++) {
values.add(children.item(childIndex).getTextContent());
}