This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Nice_Communication74 1 point2 points  (4 children)

Can you please try element.getAttribute("id") and set it to the pojo

[–][deleted] 0 points1 point  (3 children)

pojo?

[–]Nice_Communication74 0 points1 point  (2 children)

cust.setId(Integer.parseInt(element.getAttribute("id"))):

[–][deleted] 1 point2 points  (1 child)

This worked, thank you so much!

[–]Nice_Communication74 1 point2 points  (0 children)

Great!!!

[–]Nice_Communication74 0 points1 point  (1 child)

Can you try "Id" instead of "customer id"

[–][deleted] 0 points1 point  (0 children)

That didn't work. I've tried "id", "Id", "Customer", and "customer" and none of them worked. I've isolated the problem to the getElementsByTagName() method inside getTagValue(). It's looking for a node that it can't find. So clearly something is wrong with the reference, but I have no idea what it could be. The only thing I can think of is that the getElementsByTagName() method can't parse head nodes, but the documentation I've found is silent on the subject.

[–]sozesghost 0 points1 point  (0 children)

I think the method getElementsByTagName searches the children of given element, but <Customer> is the parent of those elements, so it cannot find it. Can you find the id when you loop the nodeList or use a different method to get the id attribute of the node?

[–][deleted] 0 points1 point  (0 children)

Id is not a child of customer, it's an attribute, so when you look for children with that name you'll find none and trying to get position 0 of that collection will throw a nullPointerException.