Delphi MSXML

Posted on 2006-04-26
Last Modified: 2012-05-05
I am parsing XML documents using MSXML_TLB. For example if the xml is

  <status code="63">On route to delivery branch</status>

i can get "On route to delivery branch" using
  oNodeList := oXMLDoc.selectNodes('//message');

But i don't know how to get the "code" value which is 63 for this example. if I use it like this
  oNodeList := oXMLDoc.selectNodes('//status );

it returns "On route to delivery branch"

thanks in advance
Question by:bilgehanyildirim
    LVL 1

    Accepted Solution

    Try this
    procedure TForm1.Button1Click(Sender: TObject);

      FDOM      : IXMLDOMDocument;
       amsg: string;
      FRootEL        : IXMLDOMElement;
      FEL   : IXMLDOMNode;
      AnyElement: string;
      aVariant: variant;

      amsg := memo1.text;
      FDOM := CoDOMDocument.Create;
      if not FDOM.loadXML(aMsg) then
       raise Exception.Create('Invalid XML message');

      AnyElement := 'status';
       FrootEL := FDOM.DocumentElement;
       FEl   := FrootEL.selectSingleNode('./' + AnyElement);

       if FEl <> nil  then
         aVariant :=  (FEl As IXMLDOMElement).getAttribute('code');

         if not varisNull(aVariant) then



    Author Comment

    that's it!! Thank you very much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now