Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.114 Beiträge
 
Delphi 12 Athens
 
#21

Re: himXML (gesprochen himixML)

  Alt 24. Apr 2009, 00:43
@Muetze1: mal sehn wie ich das dann umsetze.

jetzt hab ich erstmal die Variants soweit fertigbekommen

Floats werd ich noch selber umwandeln müssen ... Delphi lokalisiert ja leider das Komma, wie ich grade mitbekommen hab (blöd bei Weitergabe der XML-Datei)

die Exceptionen hab ich nun fast alle mal ordentlich umgesetzt

und wie man am Beispielcode sieht, hab ich den Index ( Node['name[i]'] ) schon drin

dieses ...
Delphi-Quellcode:
Type TMyProc = Procedure(X: Integer) of Object;

Type TForm1 = Class(TForm)
    Label1: TLabel;
    Memo1: TMemo;
    Procedure FormCreate(Sender: TObject);
  Private
  Public
    _xyz: TMyProc;
    _abc: TXMLNodeTypes;
    _va: Variant;
  Published
    Procedure MyProc(x: Integer);
    Property xyz: TMyProc read _xyz write _xyz Stored True;
    Property abc: TXMLNodeTypes read _abc write _abc Stored True Default [xtElement];
    Property va: Variant read _va write _va;
  End;

Var XML: TXMLFile;
  Node: TXMLNode;
  z: Array of Array of Array of Single;

XML := TXMLFile.Create;
Try
  Node := XML.RootNode.AddNode('node1');
  Node.Attributes['attr1'] := '123';
  Node.Attributes['attr2'] := '456';
  Node.AddNode('node1_2');
  Node := Node.AddNode('node1_3');
  Node.AddNode('node1_3_1');
  Node := XML.RootNode.AddNode('node2');
  Node := Node.AddNode('node2_1');
  Node.Attributes['attr3'] := 'abc';

  XML.Options := XML.Options + [xoNodeAutoCreate];
  XML.RootNode.AddNode('.\node1\..\node2\path\node3');
  XML.RootNode.AddNode('.\node1\..\node2\path>test=x\node4');
  XML.RootNode.AddNode('.\node1\..\node2\path\node5');
  XML.RootNode.AddNode('.\node1\..\node2\path>test=x\node6');

  Form1.abc := [xtElement];
  Form1.xyz := Form1.MyProc;
  SetLength(z, 2);
  SetLength(z[0], 3);
  SetLength(z[1], 3);
  SetLength(z[0, 0], 2);
  SetLength(z[0, 1], 2);
  SetLength(z[0, 2], 2);
  SetLength(z[1, 0], 2);
  SetLength(z[1, 1], 2);
  SetLength(z[1, 2], 2);
  z[0, 0, 0] := 000;
  z[0, 0, 1] := 001;
  z[0, 1, 0] := 010;
  z[0, 1, 1] := 011.110;
  z[0, 2, 0] := 020;
  z[0, 2, 1] := 021;
  z[1, 0, 0] := 100;
  z[1, 0, 1] := 101;
  z[1, 1, 0] := 110;
  z[1, 1, 1] := 111;
  z[1, 2, 0] := 120;
  z[1, 2, 1] := 121.121;
  Form1.va := z;
  Node := XML.RootNode.AddNode('object');
  Node.Serialize(Form1, [], SerializeProc);

  XML.SaveToFile('test.xml');
Finally
  XML.Free;
End;
... erstellt jetzt jenes
XML-Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<xml>
  <node1 attr1="123" attr2="456">
    <node1_2 />
    <node1_3>
      <node1_3_1 />
    </node1_3>
  </node1>
  <node2>
    <node2_1 attr3="abc" />
    <path>
      <node3 />
      <node5 />
    </path>
    <path test="x">
      <node4 />
      <node6 />
    </path>
  </node2>
  <object>
    <Tag>0</Tag>
    <AlignWithMargins>False</AlignWithMargins>
    <Left>132</Left>
    <Top>144</Top>
    <Cursor>0</Cursor>
    <HelpType>htContext</HelpType>
    <HelpContext>0</HelpContext>
    <Margins ClassType="TMargins">
      <Left>3</Left>
      <Top>3</Top>
      <Right>3</Right>
      <Bottom>3</Bottom>
    </Margins>
    <ParentCustomHint>True</ParentCustomHint>
    <HorzScrollBar ClassType="TControlScrollBar">
      <ButtonSize>0</ButtonSize>
      <Color>clBtnHighlight</Color>
      <Increment>8</Increment>
      <Margin>0</Margin>
      <ParentColor>True</ParentColor>
      <Position>0</Position>
      <Range>0</Range>
      <Smooth>False</Smooth>
      <Size>0</Size>
      <Style>ssRegular</Style>
      <ThumbSize>0</ThumbSize>
      <Tracking>False</Tracking>
      <Visible>True</Visible>
    </HorzScrollBar>
    <VertScrollBar ClassType="TControlScrollBar">
      <ButtonSize>0</ButtonSize>
      <Color>clBtnHighlight</Color>
      <Increment>8</Increment>
      <Margin>0</Margin>
      <ParentColor>True</ParentColor>
      <Position>0</Position>
      <Range>0</Range>
      <Smooth>False</Smooth>
      <Size>0</Size>
      <Style>ssRegular</Style>
      <ThumbSize>0</ThumbSize>
      <Tracking>False</Tracking>
      <Visible>True</Visible>
    </VertScrollBar>
    <Align>alNone</Align>
    <AlphaBlend>False</AlphaBlend>
    <AlphaBlendValue>255</AlphaBlendValue>
    <AutoSize>False</AutoSize>
    <BorderIcons>[biSystemMenu,biMinimize,biMaximize]</BorderIcons>
    <BorderStyle>bsSizeable</BorderStyle>
    <BorderWidth>0</BorderWidth>
    <Caption>Form1</Caption>
    <ClientHeight>201</ClientHeight>
    <ClientWidth>329</ClientWidth>
    <Color>clBtnFace</Color>
    <TransparentColor>False</TransparentColor>
    <TransparentColorValue>clBlack</TransparentColorValue>
    <Constraints ClassType="TSizeConstraints">
      <MaxHeight>0</MaxHeight>
      <MaxWidth>0</MaxWidth>
      <MinHeight>0</MinHeight>
      <MinWidth>0</MinWidth>
    </Constraints>
    <Ctl3D>True</Ctl3D>
    <UseDockManager>False</UseDockManager>
    <DefaultMonitor>dmActiveForm</DefaultMonitor>
    <DockSite>False</DockSite>
    <DoubleBuffered>False</DoubleBuffered>
    <DragKind>dkDrag</DragKind>
    <DragMode>dmManual</DragMode>
    <Enabled>True</Enabled>
    <ParentFont>False</ParentFont>
    <Font ClassType="TFont">
      <Charset>1</Charset>
      <Color>clWindowText</Color>
      <Height>-11</Height>
      <Name>Tahoma</Name>
      <Orientation>0</Orientation>
      <Pitch>fpDefault</Pitch>
      <Style>[]</Style>
    </Font>
    <FormStyle>fsNormal</FormStyle>
    <GlassFrame ClassType="TGlassFrame">
      <Enabled>False</Enabled>
      <Left>0</Left>
      <Top>0</Top>
      <Right>0</Right>
      <Bottom>0</Bottom>
      <SheetOfGlass>False</SheetOfGlass>
    </GlassFrame>
    <KeyPreview>False</KeyPreview>
    <Padding ClassType="TPadding">
      <Left>0</Left>
      <Top>0</Top>
      <Right>0</Right>
      <Bottom>0</Bottom>
    </Padding>[list=1]False</OldCreateOrder>
    <ParentBiDiMode>True</ParentBiDiMode>
    <PopupMode>pmNone</PopupMode>
    <Position>poDefaultPosOnly</Position>
    <PrintScale>poProportional</PrintScale>
    <Scaled>True</Scaled>
    <ScreenSnap>False</ScreenSnap>
    <SnapBuffer>10</SnapBuffer>
    <Visible>False</Visible>
    <WindowState>wsNormal</WindowState>
    <OnCreate>TForm1:Form1:FormCreate</OnCreate>
    <xyz>TForm1:Form1:MyProc</xyz>
    <abc>[xtElement]</abc>
    <va variant="Single-Array" dimensions="3">
      <dimDef0 count="2" low="0" />
      <dimDef1 count="3" low="0" />
      <dimDef2 count="2" low="0" />
      <dim0>
        <dim0>
          <dim0>0</dim0>
          <dim1>1</dim1>
        </dim0>
        <dim1>
          <dim0>10</dim0>
          <dim1>11,1099996566772</dim1>
        </dim1>
        <dim2>
          <dim0>20</dim0>
          <dim1>21</dim1>
        </dim2>
      </dim0>
      <dim1>
        <dim0>
          <dim0>100</dim0>
          <dim1>101</dim1>
        </dim0>
        <dim1>
          <dim0>110</dim0>
          <dim1>111</dim1>
        </dim1>
        <dim2>
          <dim0>120</dim0>
          <dim1>121,121002197266</dim1>
        </dim2>
      </dim1>
    </va>
    <Components>
      <Component ClassType="TLabel">
        <Tag>0</Tag>
        <AlignWithMargins>False</AlignWithMargins>
        <Left>32</Left>
        <Top>37</Top>
        <Width>31</Width>
        <Height>13</Height>
        <Cursor>0</Cursor>
        <HelpType>htContext</HelpType>
        <HelpContext>0</HelpContext>
        <Margins ClassType="TMargins">
          <Left>3</Left>
          <Top>3</Top>
          <Right>3</Right>
          <Bottom>3</Bottom>
        </Margins>
        <ParentCustomHint>True</ParentCustomHint>
        <Align>alNone</Align>
        <Alignment>taLeftJustify</Alignment>
        <AutoSize>True</AutoSize>
        <Caption>Label1</Caption>
        <Constraints ClassType="TSizeConstraints">
          <MaxHeight>0</MaxHeight>
          <MaxWidth>0</MaxWidth>
          <MinHeight>0</MinHeight>
          <MinWidth>0</MinWidth>
        </Constraints>
        <DragCursor>-12</DragCursor>
        <DragKind>dkDrag</DragKind>
        <DragMode>dmManual</DragMode>
        <EllipsisPosition>epNone</EllipsisPosition>
        <Enabled>True</Enabled>
        <GlowSize>0</GlowSize>
        <ParentBiDiMode>True</ParentBiDiMode>
        <ParentColor>True</ParentColor>
        <ParentFont>True</ParentFont>
        <ParentShowHint>True</ParentShowHint>
        <ShowAccelChar>True</ShowAccelChar>
        <Layout>tlTop</Layout>
        <Visible>True</Visible>
        <WordWrap>False</WordWrap>
      </Component>
      <Component ClassType="TMemo">
        <Tag>0</Tag>
        <AlignWithMargins>False</AlignWithMargins>
        <Left>32</Left>
        <Top>56</Top>
        <Width>257</Width>
        <Height>89</Height>
        <Cursor>0</Cursor>
        <HelpType>htContext</HelpType>
        <HelpContext>0</HelpContext>
        <Margins ClassType="TMargins">
          <Left>3</Left>
          <Top>3</Top>
          <Right>3</Right>
          <Bottom>3</Bottom>
        </Margins>
        <ParentCustomHint>True</ParentCustomHint>
        <TabStop>True</TabStop>
        <Align>alNone</Align>
        <Alignment>taLeftJustify</Alignment>
        <BevelEdges>[beLeft,beTop,beRight,beBottom]</BevelEdges>
        <BevelInner>bvRaised</BevelInner>
        <BevelKind>bkNone</BevelKind>
        <BevelOuter>bvLowered</BevelOuter>
        <BorderStyle>bsSingle</BorderStyle>
        <CharCase>ecNormal</CharCase>
        <Color>clWindow</Color>
        <Constraints ClassType="TSizeConstraints">
          <MaxHeight>0</MaxHeight>
          <MaxWidth>0</MaxWidth>
          <MinHeight>0</MinHeight>
          <MinWidth>0</MinWidth>
        </Constraints>
        <DragCursor>-12</DragCursor>
        <DragKind>dkDrag</DragKind>
        <DragMode>dmManual</DragMode>
        <Enabled>True</Enabled>
        <HideSelection>True</HideSelection>
        <ImeMode>imDontCare</ImeMode>
        <Lines ClassType="TMemoStrings">
          <Strings>
            <String>Memo1</String>
            <String />
            <String>abc</String>
          </Strings>
        </Lines>
        <MaxLength>0</MaxLength>
        <OEMConvert>False</OEMConvert>
        <ParentBiDiMode>True</ParentBiDiMode>
        <ParentColor>False</ParentColor>
        <ParentCtl3D>True</ParentCtl3D>
        <ParentDoubleBuffered>True</ParentDoubleBuffered>
        <ParentFont>True</ParentFont>
        <ParentShowHint>True</ParentShowHint>
        <ReadOnly>False</ReadOnly>
        <ScrollBars>ssNone</ScrollBars>
        <TabOrder>0</TabOrder>
        <Visible>True</Visible>
        <WantReturns>True</WantReturns>
        <WantTabs>False</WantTabs>
        <WordWrap>True</WordWrap>
      </Component>
    </Components>
  </object>
</xml>
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat