IDE: Fire_
Version: 9.2
Target: OSX
Description: I’m playing around with for each loops in Fire.
There i Use a Foreach like:
for each matching b :XmlElement in
aNode.Nodes
index i do IterateNode(indent+' > ',i,b);
Expected Behavior:
in Method IterateNode the param aNode should be always XMLElement
Actual Behavior:
it can also be an XMLText
Steps:
Full TestClass:
namespace TestXML;
interface
uses
RemObjects.Elements.RTL;
type
RTLXML = public class
private
Document : XmlDocument;
protected
method IterateNode(const indent : String; &index : Integer; const aNode : XmlElement);
public
constructor ();
method Open(aFilename : String);
end;
implementation
constructor RTLXML;
begin
end;
method RTLXML.Open(aFilename: String);
begin
Document := XmlDocument.FromFile(aFilename);
var RootNode := Document.Root;
writeLn(Document.Version);
writeLn(Document.Encoding);
IterateNode('',0,RootNode);
end;
method RTLXML.IterateNode(const indent : String; &index : Integer; const aNode: XmlElement);
begin
if aNode.NodeType = XmlNodeType.Element then
begin
writeLn(indent+'('+&index.ToString+') Node: '+aNode.LocalName);
writeLn(indent+'Attributes Count : '+aNode.Attributes.Count);
for attr in aNode.Attributes index i do
begin
&write(indent+' Attrib: ('+i.ToString+') '+attr.LocalName);
writeLn('='+attr.Value);
end;
writeLn(indent+'Nodes Count : '+aNode.Nodes.Count);
for each matching b :XmlElement in
//aNode.ElementsWithNamespace
aNode.Nodes
index i do IterateNode(indent+' > ',i,b);
end
else
begin
writeLn('******************');
writeLn('ElementType: '+aNode.NodeType);
if aNode is XmlText then
writeLn('Element is XMLElement TEXT');
writeLn('******************');
end;
end;
end.
I also add the test xmlCONTENT.XML.zip (9.7 KB)