I want to parse the xml below using dom parsing in java.
<?xml version="1.0" encoding="utf-8" ?>
<PFA date="201303312200" type="daily">
<Person id="90061" action="chg" date="31-Mar-2013">
<Gender>Male</Gender>
<ActiveStatus>Active</ActiveStatus>
<Deceased>No</Deceased>
<NameDetails>
<Name NameType="Primary Name">
<NameValue>
<TitleHonorific>Major General</TitleHonorific>
<FirstName>Aslan</FirstName>
<MiddleName>Ibraimis Dze</MiddleName>
<Surname>Abashidze</Surname>
<OriginalScriptName>مرحبا</OriginalScriptName>
</NameValue>
</Name>
</NameDetails>
</Person></PFA>
While parsing this using the following java code
public class ParseXml {
public static void main(String[] args) {
String file = "PFA2_201303312200_D.xml";
if (args.length > 0) {
file = args[0];
}
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new File(file));
System.out.println("Encoder Forment : " +document.getInputEncoding());
Element parentRoot = document.getDocumentElement();
System.out.println("Master Node is : "+parentRoot.getTagName());
for(int i =0;i<parentRoot.getChildNodes().getLength();i++){
Element root = (Element)parentRoot.getChildNodes().item(i);
The file is already a utf-8 file and while reading the data from a IDE (Eclipse) I m getting the data other language scripts as ???????
. How can I resolve this?