We've been using Stefan Heymann's XML parser for a long time, it supports D4 and above, is open source, and is very easy to use. Info here: http://www.destructor.de/xmlparser/index.htm.

At 03:31 AM 1/27/2011, Brendan Blake wrote:

Delphi provides a wrapper component designed to read, create and parse XML
documents: TXMLDocument, which I think would make your job much easier.

But you won't have this if you are using Delphi 5 - it was first released in
Delphi 7 I recall.

You can read about using XML with Delphi here, but I think this is based on
later versions of Delphi than yours....
http://delphi.about.com/od/windowsshellapi/a/xml_delphi.htm

Maybe someone has worked out how to port TXMLDocument back onto Delphi5....
might be quite easy if you have the Delphi 7 source.  Otherwise - upgrade?

Regards,
       Brendan Blake.


-----Original Message-----
From: delphi-boun...@elists.org [mailto:delphi-boun...@elists.org] On Behalf
Of Steve Bowker
Sent: 26 January 2011 09:44
To: delphi elists
Subject: Delphi & MSXML

Hi,
Has anyone had any experience of using Delphi (5) & MSXML?  I can't seem to
find any decent example code or tutorials on Google.

I've got as far as receiving the XML via a client socket, so have the XML as
one long string.
Here is the sample XML as it would look in text format:
<query>
  <result>success</result>
  <id>01234567890</id>
  <balance>54.50</balance>
  <tickets>320</tickets>
  <holder_title>Mr</holder_title>
  <holder_firstname>Steve</holder_firstname>
  <holder_surname>Smith</holder_surname>
</query>

The 1st element after <query> will always be <result> and if 'success'  it
is followed by the returned elements above, else it will return elements
containing <failcode> & <failreason>

Here's the (not very elegant) pseudo code of what I want to do with this,
can anyone provide the actual Delphi(5) code to acheive this?

uses
  MSXML2_TLB;

procedure ProcessAllelementsFromXML;
var
  ElementName, ElementValue: string;
  Doc: IXMLDOMDocument;
begin
  Doc := CoDOMDocument.Create;

if Doc.LoadXML(strXML) then
begin
  if Doc.RootNode = '<query>' then
  begin
    for i := 0 to NumberOfElementsWithinQueryNode do
    begin
      ElementName := Doc.ElementName[i];
      ElementValue := Doc.ElementValue[i];
      if ElementName = 'success' then
        carry on with loop and populate some text fields from ElementName &
Value
      else
        carry on with loop and process each <failcode> & <failreason>
    end;
  end
  else if Root Node = 'adjust' then
  begin
    as above but different element names are processed slightly differently
  end;
end;
end;

Thanks in advance for any help,
Steve
_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Regards,
Sid Gudes
PIA Systems Corporation
sid.gu...@piasystems.com

_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to