Reading in XML File, slightly unusual format

jkeoghjkeogh Member Posts: 5
I have an XML file of the following format.
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header /> 
- <SOAP-ENV:Body>
- <ns2:ReportResponse xmlns:ns2="http://www.webexpenses.com/reports/schemas" xmlns:ns3="http://www.webexpenses.com/ws/schemas" xmlns:ns4="http://www.webexpenses.com/ws/mobile/schemas">
  <ns2:responseTitle /> 
- <ns2:responseBody>
- <ns2:resultRow>
  <ns2:result Name="vatRate" Value="21.0" /> 
  <ns2:result Name="status" Value="Submitted" /> 
  <ns2:result Name="claimId" Value="12" /> 
  <ns2:result Name="companyName" Value="Healthcare Ltd" /> 
  <ns2:result Name="dateCreated" Value="26-07-2011" /> 
  <ns2:result Name="claimItemDesc" Value="Visit customer in Cork" /> 
  <ns2:result Name="amount" Value="200.0000" /> 
  <ns2:result Name="amountWithoutVat" Value="165.2900" /> 
  <ns2:result Name="claimDesc" Value="" /> 
  <ns2:result Name="accountsPersonName" Value="Accounts, Test ROI" /> 
  <ns2:result Name="categoryGlCode" Value="52500" /> 
  <ns2:result Name="categoryName" Value="Hotels" /> 
  <ns2:result Name="datePaid" Value="" /> 
  </ns2:resultRow>
- <ns2:resultRow>
  <ns2:result Name="vatRate" Value="21.0" /> 
  <ns2:result Name="status" Value="Submitted" /> 
  <ns2:result Name="claimId" Value="12" /> 
  <ns2:result Name="companyName" Value="Healthcare Ltd" /> 
  <ns2:result Name="dateCreated" Value="26-07-2011" /> 
  <ns2:result Name="claimItemDesc" Value="Car hire RE visit to customer in cork" /> 
  <ns2:result Name="amount" Value="200.0000" /> 
  <ns2:result Name="amountWithoutVat" Value="165.2900" /> 
  <ns2:result Name="claimDesc" Value="" /> 
  <ns2:result Name="accountsPersonName" Value="Accounts, Test ROI" /> 
  <ns2:result Name="categoryGlCode" Value="52800" /> 
  <ns2:result Name="categoryName" Value="Car Hire" /> 
  <ns2:result Name="datePaid" Value="" /> 
  </ns2:resultRow>
  ............... etc


and am accessing it as follows.
XMLNode := XMLDocument.documentElement;
XMLRootNode := XMLDocument.documentElement;

WITH XMLDOMManagement DO 
BEGIN
   XMLDOMManagement.SetNormalCase;
   IF FindNode(XMLNode,'SOAP-ENV:Body',XMLNodeFound) THEN BEGIN
      XMLNode := XMLNodeFound;
      IF FindNode(XMLNode,'ns2:ReportResponse',XMLNodeFound) THEN BEGIN
         XMLNode := XMLNodeFound;
         IF FindNode(XMLNode,'ns2:responseBody',XMLNodeFound) THEN BEGIN
            XMLNode := XMLNodeFound;
            IF FindNode(XMLNode,'ns2:resultRow',XMLNodeFound) THEN BEGIN
               XMLNode := XMLNodeFound;
               IF FindNode(XMLNode,'ns2:result',XMLNodeFound) THEN BEGIN
                  XMLNode := XMLNodeFound;
                  IF FindNode(XMLNode,'Name',XMLNodeFound) THEN
                  BEGIN
                     XMLNode := XMLNodeFound;
                  END;
               END;
            END;
         END;
      END;
   END;
END;

So that gets me from the top of the file down to ns2:result, and then obviously it fails doing the FindNode of 'Name' as its clearly not a Node.
But how exactly do I access 'Name' and 'Value' inside ns2:result ?


edit :
Solved using specially written 'get atttribute' function, and looping through these attributes returning their value.
pm jkeoghatsyscodotie if want the code used.
Sign In or Register to comment.