Hi All,
I have written the below JAVA file for reading my XML file and provide me the all LastName Value.
But if I am doing this like using below , then I am getting error.
//logger.info("LASTNAME VALUE from ==== " + element.getElementsByTagName("LastName").item(i).getTextContent());
********************* MY XML FILE ****************************
Can anyone please help me how can I do this ?
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Can you add the specific error that you are getting during accessing the element .
Also can you update the reading part with the below lines and see if that works
// first line optional
// http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
NodeList list = doc.getElementsByTagName("UniqueEntry");
for (int temp = 0; temp < list.getLength(); temp++) {
Node node = list.item(temp);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
String lastname=element.getElementsByTagName("LastName").item(0).getTextContent();
}
}
Can you add the specific error that you are getting during accessing the element .
Also can you update the reading part with the below lines and see if that works
// first line optional
// http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
NodeList list = doc.getElementsByTagName("UniqueEntry");
for (int temp = 0; temp < list.getLength(); temp++) {
Node node = list.item(temp);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
String lastname=element.getElementsByTagName("LastName").item(0).getTextContent();
}
}
@SunitaCh Did you find the suggestion from @sherinregi helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Views
Likes
Replies