title: Delphi XML - obtaining a value from parent node
body: <p>I am new to using XML in Delphi, and have used the questions already posted to find out most of what I need to know (thank you!).  However ... I am struggling to obtain a data value from the top of the XML file issued by one of our suppliers.</p>
  
  <p>The top of the XML file is shown below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;form billId="1004" penId="ABCDE" appName="Report Sheet" penSerialNo="AJX-AAT-AGK-B4" &gt;
  &lt;question id="1" reference="site_name" value="Acme Inc" /&gt;&lt;/question&gt;
  &lt;question id="2" reference="site_address" value="London" /&gt;&lt;/question&gt;
  &lt;question id="3" reference="TQM_job_no" value="AB1234567" /&gt;&lt;/question&gt;
  &lt;question id="4" reference="TQM_site_no" value="XX999" /&gt;&lt;/question&gt;
  </code></pre>
  
  <p>How can I obtain the <strong>penId</strong> and <strong>penSerialNo</strong> values?</p>
  
  <p>For reference, I am using the code below, obtained from another post on the site, to traverse the XML and obtain the values from the <em>question</em> nodes:</p>
  
  <pre><code>for i:= 0 to XMLDocument1.DocumentElement.ChildNodes.Count - 1 do
     begin
         Node:= XMLDocument1.DocumentElement.ChildNodes[I];
   if Node.NodeName = 'question' then
    begin
     if Node.HasAttribute('value') then
      VALUEvar:= Node.Attributes[value'];
      // do something with VALUEvar which is a string
        end;
  end;
  end;
  </code></pre>
  
  <p>I would really appreciate any help that could be provided ... thanks in advance!</p>