xmlAttributeCollection
Hi,
trying to get the attribute list from an xml file, I use xmlAttributecollection but cannot get the list of attributes.
here is my code: xmlNode: XmlNode; xmlAttributeList: XmlAttributeCollection; xmlAttribute: XmlAttribute;
xmlNodeList := pTableDATA.GetChildNodes(); (pTableDATA is an xmlFile as listed below)
for i := 1 to xmlNodeList.Count do begin
xmlNodeList.Get(i, xmlNode);
xmlElement2 := xmlelement.create('Attributes');
xmlElement2.add(xmlNode);
xmlAttributeList := xmlElement2.Attributes();
Message('xmlAttributeList.Count ' + Format(xmlAttributeList.Count));
the message shows value of 0, here is the xml file:

I have the same issue, once I do VarXmlNodeList.Get(0, VarXmlNode) I get an error message with "0".
@thloke ,why is this marked as a question? It seems a bug to me...
@angela2389 The Get() method on XmlNodeList is 1-based like most of AL. It is also stated in the documentation https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/xmlnodelist/xmlnodelist-get-method.
The error-message is lacking and will be updated.
@abouraoui The code sample does exactly what it should.
xmlElement2 := xmlelement.create('Attributes');
Creates a new element named 'Attribute' e.g.
xmlElement2.add(xmlNode)
Add the content of xmlNode to the newly created element e.g.
xmlAttributeList := xmlElement2.Attributes();
Gets a list of attributes on the