It depends on how your XML document was created. In particular, it can have multiple text node nodes in "H and M", while your code expects it to be one. Try using nodeVariable.normalize () before getting its value.
API- DOM: "normalize() - Node, , " ", (, , , , CDATA ) , .. , ..."