AL icon indicating copy to clipboard operation
AL copied to clipboard

Getting text value's out of XmlNodes makes D365 crash

Open AMCJN opened this issue 9 years ago • 1 comments

Our procedure for getting text value's out of XmlNodes according to Github "How to get XmlText from XmlNode?" #556

local procedure getNodeValue(ParentXmlNode : XmlNode;Xpath : Text) : Text; var DataXmlNode : XmlNode; NodeValue : Text; begin if(ParentXmlNode.SelectSingleNode(Xpath+'/text()',DataXmlNode)) then begin if(DataXmlNode.IsXmlText) then begin NodeValue := DataXmlNode.AsXmlText.Value; if(NodeValue <> '') then EXIT(DELCHR(NodeValue,'=', '"')) else EXIT('');
end; end;

EXIT('');
end;

Eventviewer.pdf

But the line 'NodeValue := DataXmlNode.AsXmlText.Value;' makes D365 crash and the eventviewer shows and null pointerexception, if the selected node does not have any value.

According to Github How do I use ISNULL? #554, this should not happen when using SelectSingleNode function for AL XML types.

XML example :

<keyvalueid>
   <key>KEYNAME</key>
  	   <value/>
</keyvalueid>

It is the nodename value that fails, because it does not have any text value. This is a major problem for us, because there can be many nodesnames without any textvalue.

AMCJN avatar Sep 04 '17 21:09 AMCJN

You are right, the crash should not happen. I will investigate and get back to you

atoader avatar Sep 05 '17 07:09 atoader