Parsing XML in Crystal Reports Formula Language

461 Views Asked by At

I have an XML file i just imported into Crystal Reports 2016 as an ADO.NET (XML) DataSet . I'm trying to parse some of the information on the DataSet i only get one entry on the xml instead of the list i desire to get .

    <Problem>
      <Person>
        <Name>
           <FirstName> Clausen </FirstName>
        </Name>
      </Person>
      <Person>
        <Name>
          <FirstName> Mario </FirstName>
        </Name>
      </Person>
  </Problem>

On Crystal Reports formula Workshop i've tried using the code :

 whileprintingrecords;

 stringvar name := {Person.Name};

And what i get is just the last name

After searching the internet i found this For loop:

whileprintingrecords;

stringvar array x := split({Person.Name},"</");
numbervar i:= 0 ;
numbervar j := unbound(x);
stringvar array y;
numbervar k ;

for i := 1 to j do(
if instr(x[i],"<Name>") <> 0 then(
k := k+1;
redim preserve y[j];
y[k] := extractstring(x[i],"<Name>","</Name>")) [i]);

stringvar Name := y[k]; 

After trying both codes i only get the last name instead of the two i want.

0

There are 0 best solutions below