I have a following xml structure which may have any file type like PDF,EXCEL,TEXT files:
<document>
<reference>
<text mediaType="text/plain" representation="B64">
<reference value="Attachment For Sambar.txt" />
aGVsbG9fZHVkZS1hd2Vzb21lLnJ1
</text>
</document>
Based on the type i need to extract the value(File attachemnt) from reference tag... here is the code i have tried..
NodeList nList = doc.getElementsByTagName("text");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
if(nNode.getNodeName()=="text"){
System.out.println(eElement.getAttribute("mediaType")+"*&*&");
System.out.println(eElement.getNodeValue()+"^%%$%%%%%%%%Hhhhhhhhhhhhhhhhh");
//NOTE : This throws me null pointer exception
}
}
}
I would like to know how to extract attachments from the reference tag...the above code throws me null pointer exception