Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Delphi 10.2.3 und XML (https://www.delphipraxis.net/196591-delphi-10-2-3-und-xml.html)

franktron 1. Jun 2018 13:37

Delphi-Version: 10.2 Tokyo

Delphi 10.2.3 und XML
 
Ich möchte eine XML Datein lesen

Code:
<?xml version="1.0"?>
<config>
    <db>
        <username>dfdff</username>
        <password>dfdfd</password>
        <server>1.1.1.1.</server>
        <db>dfdfdffdf</db>
        <dbport>3306</dbport>
        <povider>MySQL</povider>
    </db>
   <port>35353</port>
     <httpport>88</httpport>
</config>
Hier ist mein Code
Delphi-Quellcode:
var
  LDocument: IXMLDocument;
  LNodeElement : IXMLNode;
begin
  LDocument := TXMLDocument.Create(nil);
  if FileExists(FConfigFile) then
  Begin
    LDocument.LoadFromFile(FConfigFile);
    LNodeElement:=LDocument.DocumentElement.ChildNodes['db'];
    if LDocument<>Nil then
    Begin
      FDB.UserName:=LDocument.DocumentElement.ChildNodes['db'].ChildNodes.Nodes['username'].NodeValue;
      FDB.UserName:=LNodeElement.ChildNodes.FindNode('username').Text;
      FDB.Password:=LNodeElement.ChildNodes.FindNode('password').Text;
      FDB.Server:=LNodeElement.ChildNodes.FindNode('server').Text;
      FDB.DB:=LNodeElement.ChildNodes.FindNode('db').Text;
      FDB.Port:=StrToIntDef(LNodeElement.ChildNodes.FindNode('port').Text,3306);
      FDB.Provider:=LNodeElement.ChildNodes.FindNode('provider').Text;
    End;
    LNodeElement:=LDocument.ChildNodes.FindNode('config');
    if LDocument<>Nil then
    Begin
      FPort:=StrToIntDef(LNodeElement.ChildNodes.FindNode('port').Text,88);
    End;
  End;
Vorher habe ich noch
DefaultDOMVendor:=sOmniXmlVendor;

Jetzt zu meine Problem ich bekomme immer Exceptions egal was ich versuche.

Habe ich da irgendwo ein Gedanken Fehler

mber 1. Jun 2018 13:59

AW: Delphi 10.2.3 und XML
 
versuch mal:

LDocument.Active := True;

direkt nach dem Document.Loadfromfile....

franktron 1. Jun 2018 14:39

AW: Delphi 10.2.3 und XML
 
Danke das war es


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:04 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz