Changeset 138 for trunk/Packages/CoolWeb/Common/UXmlClasses.pas
- Timestamp:
- Sep 9, 2022, 8:20:25 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CoolWeb/Common/UXmlClasses.pas
r137 r138 4 4 5 5 uses 6 Classes, SysUtils, StrUtils, SpecializedList, SpecializedDictionary;6 Classes, SysUtils, StrUtils, Generics.Collections, UGenerics; 7 7 8 8 type … … 12 12 public 13 13 property AsString: string read GetAsString; 14 end; 15 16 TXmlTag = class; 17 TXmlString = class; 18 19 { TXmlElements } 20 21 TXmlElements = class(TObjectList<TXmlElement>) 22 function AddTag(Name: string): TXmlTag; 23 function AddString(Text: string): TXmlString; 14 24 end; 15 25 … … 29 39 Name: string; 30 40 Attributes: TDictionaryStringString; 31 SubElements: T ListObject; // TListObject<TXmlElement>;41 SubElements: TXmlElements; 32 42 constructor Create; 33 43 destructor Destroy; override; … … 52 62 implementation 53 63 64 { TXmlElements } 65 66 function TXmlElements.AddTag(Name: string): TXmlTag; 67 begin 68 Result := TXmlTag.Create; 69 Result.Name := Name; 70 Add(Result); 71 end; 72 73 function TXmlElements.AddString(Text: string): TXmlString; 74 begin 75 Result := TXmlString.Create; 76 Result.Text := Text; 77 Add(Result); 78 end; 79 54 80 { THtmlElement } 55 81 … … 58 84 ShringEmpty := True; 59 85 Attributes := TDictionaryStringString.Create; 60 SubElements := T ListObject.Create;86 SubElements := TXmlElements.Create; 61 87 EndTagSymbol := '/'; 62 88 end; … … 64 90 destructor TXmlTag.Destroy; 65 91 begin 66 Attributes.Free;67 SubElements.Free;92 FreeAndNil(Attributes); 93 FreeAndNil(SubElements); 68 94 inherited; 69 95 end; … … 74 100 I: Integer; 75 101 Content: string; 102 Attribute: TPair<string, string>; 76 103 begin 77 104 Content := ''; … … 80 107 81 108 AttributesText := ''; 82 for I := 0 to Attributes.Count - 1do83 AttributesText := AttributesText + ' ' + Attribute s.Keys[I] + '="' + Attributes[I].Value + '"';109 for Attribute in Attributes do 110 AttributesText := AttributesText + ' ' + Attribute.Key + '="' + Attribute.Value + '"'; 84 111 85 112 if Name <> '' then begin … … 123 150 destructor TXmlDocument.Destroy; 124 151 begin 125 Content.Free;126 MainTag.Free;152 FreeAndNil(Content); 153 FreeAndNil(MainTag); 127 154 inherited; 128 155 end;
Note:
See TracChangeset
for help on using the changeset viewer.