Hello Adewale ,
try this-
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(fileStream);
String id = document.getElementsByTagName("data").item(0).getAttributes().getNamedItem("id").getNodeValue();
where fileStream is stream to your input file.
One more thing i would like to say is your id attribute value must be in single or double quotes! i.e. like
<data id='1'>
let me know is this is suffice for you!