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

Reply via email to