Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread XML parsing problem
Wed, Nov 6 2013 12:09 PMPermanent Link

aberas

I'm trying to parse an XML with this general format:

<DOC>
   <A>somevalue</A>
   <B>othervalue</B>
   <validation class="list">
      <receipt>
         <number>00011</number>
         <processed>NO</processed>
         <errors class="list">
            <error>
               <code>01</code>
               <description>Wrong number.</description>
            </error>
            <error>
               <code>02</code>
               <description>Wrong name.</description>
            </error>
         </errors>
      </receipt>
      <receipt>
         <number>00012</number>
         <processed>NO</processed>
         <errors class="list">
            <error>
               <code>03</code>
               <description>Wrong article.</description>
            </error>
         </errors>
      </receipt>
   </validation>
</DOC>

from wich I need to extract, among other things, the errors.
I need to get this values: errors count =2 //  errors[1] error count =2 //  errors[2] error count =1  and the reference to parse the errors, but I'm not being able to...

Can some caritative soul lend me a hand?
Fri, Nov 8 2013 4:29 AMPermanent Link

Matthew Jones

This should get you going:

procedure TfrmClicker.ParseQuestionXML(szXML : String);
var
   nProposedHeight : Integer;
   respDoc: TDocument;
begin
   respDoc := getDOMfromXMLstring(szXML);
   xDataNodeList := respDoc.getElementsByTagName('Anonymous');
   if xDataNodeList.Length > 0 then
   begin
       szAnonymousMode := xDataNodeList[0].firstChild.nodeValue;
       if m_bAnonymousMode and (szAnonymousMode = 'forbidden') then
       begin
           bVotingEnabled := false;
       end;
   end;
....

/Matthew Jones/
Image