Ignore:
Timestamp:
Jun 19, 2024, 11:15:44 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/XML.pas

    r314 r315  
    1 unit UXMLUtils;
    2 
    3 {$mode delphi}
     1unit XML;
    42
    53interface
     
    1614procedure WriteString(Node: TDOMNode; Name: string; Value: string);
    1715procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime);
     16procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double);
    1817function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    1918function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64;
     
    2120function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    2221function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime;
     22function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double;
    2323procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
    2424
    2525
    2626implementation
     27
     28function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double;
     29var
     30  NewNode: TDOMNode;
     31begin
     32  Result := DefaultValue;
     33  NewNode := Node.FindNode(DOMString(Name));
     34  if Assigned(NewNode) then
     35    Result := StrToFloat(string(NewNode.TextContent));
     36end;
    2737
    2838procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
     
    202212end;
    203213
     214procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double);
     215var
     216  NewNode: TDOMNode;
     217begin
     218  NewNode := Node.OwnerDocument.CreateElement(DOMString(Name));
     219  NewNode.TextContent := DOMString(FloatToStr(Value));
     220  Node.AppendChild(NewNode);
     221end;
     222
    204223function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    205224var
     
    254273
    255274end.
    256 
Note: See TracChangeset for help on using the changeset viewer.