Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-07

Problem reading an XML file

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Meyer

I'm trying to retrieve an XML file from a web site but I'm not able to do it through this code. Maybe I'm being a little too VB-ish, but here's my code:

procedure TForm1.btnRetrieveFriendsClick(Sender: TObject);
var
   TwitterDoc: TXMLDocument;
   Child: TDOMNode;
   j: Integer;
   strURL: AnsiString;
   ID: TDOMNode;
   UserName: TDOMNode;
begin
     strURL := 'http://twitter.com/statuses/friends/' + edUserName.Text
+ '.xml';
     ReadXMLFile(TwitterDoc,strURL);
     Child := TwitterDoc.DocumentElement.FirstChild;
     while Assigned(Child) do
     begin
     UserName := Child.FindNode('name');
     ID := Child.FindNode('id');
     lstFriends.Items.Add(UserName.NodeValue + '(' + ID.NodeValue + ')');
     Child := Child.NextSibling;
     end;
end;

Reply by email

Sergei Gorelkin
to John Meyer
John Meyer wrote
I'm trying to retrieve an XML file from a web site but I'm not able to do it through this code. Maybe I'm being a little too VB-ish, but here's my code:

Reading xml files directly from http isn't supported yet. You have to retrieve the data from network using some other means. Once you have the data in a local file or in a stream, use ReadXMLFile to parse it.

Regards,
Sergei

Show quoted text 24 lines
procedure TForm1.btnRetrieveFriendsClick(Sender: TObject); var TwitterDoc: TXMLDocument; Child: TDOMNode; j: Integer; strURL: AnsiString; ID: TDOMNode; UserName: TDOMNode; begin strURL := 'http://twitter.com/statuses/friends/' + edUserName.Text + '.xml'; ReadXMLFile(TwitterDoc,strURL); Child := TwitterDoc.DocumentElement.FirstChild; while Assigned(Child) do begin UserName := Child.FindNode('name'); ID := Child.FindNode('id'); lstFriends.Items.Add(UserName.NodeValue + '(' + ID.NodeValue + ')'); Child := Child.NextSibling; end; end;

Reply by email

John Meyer
to Sergei Gorelkin
Sergei Gorelkin wrote 7 lines
> Reading xml files directly from http isn't supported yet. You have to retrieve the data from network using some other means. Once you have the data in a local file or in a stream, use ReadXMLFile to parse it. Regards, Sergei

I was thinking about using CurlPas from what I've read. Is that natively installed in Lazarus, or do I have to download that somewhere else?

Reply by email