Delphi XML - obtaining a value from parent node

Sriyegna

New Member
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.The top of the XML file is shown below:\[code\]<?xml version="1.0" encoding="utf-8"?><form billId="1004" penId="ABCDE" appName="Report Sheet" penSerialNo="AJX-AAT-AGK-B4" ><question id="1" reference="site_name" value="http://stackoverflow.com/questions/10429466/Acme Inc" /></question><question id="2" reference="site_address" value="http://stackoverflow.com/questions/10429466/London" /></question><question id="3" reference="TQM_job_no" value="http://stackoverflow.com/questions/10429466/AB1234567" /></question><question id="4" reference="TQM_site_no" value="http://stackoverflow.com/questions/10429466/XX999" /></question>\[/code\]How can I obtain the penId and penSerialNo values?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 question nodes:\[code\]for i:= 0 to XMLDocument1.DocumentElement.ChildNodes.Count - 1 do begin Node:= XMLDocument1.DocumentElement.ChildNodes; 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\]I would really appreciate any help that could be provided ... thanks in advance!
 
Back
Top