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

Legend:

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

    r29 r30  
    1 unit UXMLUtils;
     1unit XML;
    22
    33interface
     
    1414procedure WriteString(Node: TDOMNode; Name: string; Value: string);
    1515procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime);
     16procedure WriteDouble(Node: TDOMNode; Name: string; Value: Double);
    1617function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    1718function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64;
     
    1920function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    2021function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime;
     22function ReadDouble(Node: TDOMNode; Name: string; DefaultValue: Double): Double;
    2123procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
    2224
    2325
    2426implementation
     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;
    2537
    2638procedure ReadXMLFileParser(out Doc: TXMLDocument; FileName: string);
     
    200212end;
    201213
     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
    202223function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    203224var
     
    252273
    253274end.
    254 
Note: See TracChangeset for help on using the changeset viewer.