Thema: Delphi RDF auslesen

Einzelnen Beitrag anzeigen

Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#7

Re: RDF auslesen

  Alt 14. Feb 2004, 12:06
Hallo,
ich habe mich wegen dieses Threads zum ersten mal mit XMlDocument beschäftigt.
Deshalb habe ich mir die Typebibliothek der Verion 5 (kam mit Office 2003) importiert
(mit Komponentenwrapper deshalb steht im Sourc immer DefaultInterface).
Damit habe ich dann versucht das Beispiel nachzuvollziehen. Hat auch geklappt.
Delphi-Quellcode:
unit xml_main_frm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MSXML5_TLB, StdCtrls, OleServer;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    XMLDoc: TMSDOMDocument50;
    procedure Button1Click(Sender: TObject);
    procedure XMLDocondataavailable(Sender: TObject);
  private
    { Private-Deklarationen }
    procedure LoadXML_List(const Source : String);
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  ListBox1.Clear;
  LoadXML_List('http://www.delphipraxis.com/rdf.php');
end;

procedure TForm1.LoadXML_List(const Source: String);
begin
  XMLDoc.DefaultInterface.load(Source);
end;

procedure TForm1.XMLDocondataavailable(Sender: TObject);
var
  xmlTopics : IXMLDOMNodeList;
  iCnt : Integer;
  jCnt : Integer;
begin
  If XMLDoc.DefaultInterface.parseerror.errorCode=0 then
    begin
// XMLDoc.DefaultInterface.SetProperty('SelectionNamespaces','xmlns:na="http://my.netscape.com/rdf/simple/0.9/"');

    xmlTopics := xmlDoc.DefaultInterface.documentElement.childNodes;
    For iCnt := 0 to xmlTopics.length-1 do
      begin
      For jCnt:=0 to xmlTopics.item[iCnt].childNodes.length-1 do
        ListBox1.Items.Add(xmlTopics.item[iCnt].childNodes.item[jCnt].Text+' : '+
        xmlTopics.item[iCnt].childNodes.item[jCnt].nodeName);
      ListBox1.Items.Add('----');
      end;
    end
      else
        ShowMessage('Fehler beim parsen');
end;

end.
Bei mir funktioniert es auch ohneXMLDoc.DefaultInterface.SetProperty('SelectionNamespaces','xmlns:na="http://my.netscape.com/rdf/simple/0.9/"'); D.h. mit XMLDoc.DefaultInterface.SetProperty('SelectionNamespaces','xmlns:na="http://my.netscape.com/rdf/simple/0.9/"'); funktioniert es bei mir nicht. Sonderbar ???
  Mit Zitat antworten Zitat