Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#7

AW: XMLDocument zur Laufzeit -> Exception

  Alt 21. Mai 2015, 16:38
Sowas halt (falls du wie gesagt irgendwas anderes rumfliegen hast, dann kannst du das stattdessen auch übergeben und musst keine temporäre Instanz erstellen):

Delphi-Quellcode:
function LoadWebData(xmlResponse : TMemoryStream) : boolean;
var
  XMLDoc : TXMLDocument;
  StartItemNode: IXMLNode;
  dummyComp: TComponent;
begin
  Result := true;
  
  dummyComp := TComponent.Create(nil); // <--
  try
    XMLDoc := TXMLDocument.Create(dummyComp); // <--
    try
      XMLDoc.DOMVendor := DOMVendors.Find('Omni XML');
      XMLDoc.Options := [doAttrNull,doAutoPrefix,doNamespaceDecl];

      try
        XMLDoc.LoadFromStream(xmlResponse);
      except;
        Result := false;
        exit;
      end;
      XMLDoc.Active := True;

      try
        StartItemNode := XMLDoc.DocumentElement.ChildNodes.FindNode('response') ; // <= Exception
      except
      end;
  // ....
    finally
      XMLDoc.Active := false;
      XMLDoc := NIL;
    end;
  finally
    dummyComp.Free;
  end;
end;
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat