Iterate over all children elements of given XML element.
Without this, typical iteration looks like
varIndex: Integer;
ChildrenList: TDOMNodeList;
ChildNode: TDOMNode;
ChildElement: TDOMElement;
begin
ChildrenList := Element.ChildNodes;
tryforIndex := 0to ChildrenList.Count - 1dobegin
ChildNode := ChildrenList.Item[Index];
if ChildNode.NodeType = ELEMENT_NODE thenbegin
ChildElement := ChildNode as TDOMElement;
... here goes your code to process ChildElement ...
end;
end;
finally FreeChildNodes(ChildrenList); end;
end;
... which is an easy code, but it becomes tiresome to write this over and over again, especially for units that heavily process XML (like X3D XML or Collada readers). So this class allows you to write instead
var
I: TXMLElementIterator;
begin
I := TXMLElementIterator.Create(Element);
trywhile I.GetNext dobegin
... here goes your code to process I.Current ...
end;
finally FreeAndNil(I) end;
end;