2016. 8. 29. 08:59

관련 API는


https://www.hometax.go.kr/websquare/websquare.wq?w2xPath=/ui/pp/index_pp.xml&tmIdx=0&tm2lIdx=100907&tm3lIdx=#


에 있음.(연말정산간소화-전자문서API자료실)


PDF-XML 변환 후 구조 분석하여 전체 쪼개기에 성공함


안드로이드에서 했던 pullparser같은 간편한 구조는 구현을 못하고...


무식하게 for문과 if문으로 돌림. 4단계이므로 for문 변수가 4개나 필요했다.ㅜㅜ


IXMLDomNode 사용. uses에 MSXML 추가.


최상단 form_cd로 루틴 나누고


값별로 함수 다 떼내서 구현.


그리고 월/일별 반복구간(M이나 D로 끝날때)이 있어 또한번 좌절 후 처리.


이제 뜯은 내용 db와 연결하고 UI부분 손대면 큰일은 끝나는걸로.



아래 소스는... 연말정산 항목 변경이 자주 있을 거 같아서 어떻게든 동적으로 처리해보려고 하다 실패한 소스. 차후 다시 연구해볼 예정. IXMLDomNode를 어떻게 쓰면 되겠다 하는 정도는 파악할 수 있을듯.


procedure Tfrmhr019c00.yesoneForm(attributes:IXMLDOMNamedNodeMap;nodes: IXMLDomNodeList);

var

  tmpNode: TcxTreeListNode;

  node: IXMLDomNode;

  i, j, k, l, m: Integer;


  tmpCol: TcxTreeListColumn;

  tmpcxTabSheet: TcxTabSheet;

  tmpcxTreeList: TcxTreeList;

  tmpnodes: Array of IXMLDomNodeList;

  tmpvalues: Array of String;

begin

  m := 0;


  SetLength(tmpnodes, 5);

  tmpcxTabSheet := TcxTabSheet.Create(Self);

  tmpcxTabSheet.Caption := 'yesone' + attributes.item[0].text;

  tmpcxTabSheet.PageControl := cxPC1;


  tmpcxTreeList := TcxTreeList.Create(Self);

  tmpcxTreeList.Align := alClient;

  tmpcxTreeList.Name := 'cxTL' + attributes.item[0].text;

  tmpcxTreeList.Bands.Add;

  tmpcxTreeList.Parent := tmpcxTabSheet;


  with tmpcxTreeList do

  begin

    Clear;

    BeginUpdate;


    For i := 0 To Bands[0].ColumnCount -1 Do

    Begin

      Bands[0].Columns[0].Free;

    End;


    For i := 0 To attributes.length -1 Do//form att

    Begin

      try

        tmpCol := CreateColumn(Bands[0]);

        tmpCol.Name := tmpcxTreeList.Name + attributes.item[i].nodeName;

        tmpCol.Position.BandIndex := 0;

        tmpCol.Width := 100;

        tmpCol.Caption.AlignHorz := taCenter;

        tmpCol.Caption.Text := attributes.item[i].nodeName;

      except

        Bands[0].Columns[ColumnCount-1].Free;

      end;

    End;


    For i := 0 To nodes.length - 1 Do

    //For i := 0 To 0 Do

    Begin

      For j := 0 To nodes.item[i].attributes.length -1 Do//man att

      Begin

        try

          tmpCol := CreateColumn(Bands[0]);

          tmpCol.Name := tmpcxTreeList.Name + nodes.item[i].attributes.item[j].nodeName;

          tmpCol.Position.BandIndex := 0;

          tmpCol.Width := 100;

          tmpCol.Caption.AlignHorz := taCenter;

          tmpCol.Caption.Text := nodes.item[i].attributes.item[j].nodeName;

        except

          Bands[0].Columns[ColumnCount-1].Free;

        end;

      End;

      For j := 0 To nodes.item[i].childNodes.length - 1 Do

      //For j := 0 To 0 Do

      Begin

        tmpnodes[0] := nodes.item[i].childNodes;

        For k := 0 To tmpnodes[0].item[j].attributes.length -1 Do//data att

        Begin

          try

            tmpCol := CreateColumn(Bands[0]);

            tmpCol.Name := tmpcxTreeList.Name + tmpnodes[0].item[j].attributes.item[k].nodeName;

            tmpCol.Position.BandIndex := 0;

            tmpCol.Width := 100;

            tmpCol.Caption.AlignHorz := taCenter;

            tmpCol.Caption.Text := tmpnodes[0].item[j].attributes.item[k].nodeName;

          except

            Bands[0].Columns[ColumnCount-1].Free;

          end;

        End;

        For k := 0 To tmpnodes[0].item[j].childNodes.length - 1 Do

        //For k := 0 To 0 Do

        Begin

          tmpnodes[1] := tmpnodes[0].item[j].childNodes;


          try

            tmpCol := CreateColumn(Bands[0]);

            tmpCol.Name := tmpcxTreeList.Name + tmpnodes[1].item[k].nodeName;

            tmpCol.Position.BandIndex := 0;

            tmpCol.Width := 100;

            tmpCol.Caption.AlignHorz := taCenter;

            tmpCol.Caption.Text := tmpnodes[1].item[k].nodeName;

          except

            Bands[0].Columns[ColumnCount-1].Free;

          end;

          For l := 0 To tmpnodes[1].item[k].attributes.length -1 Do//amt att

          Begin

            try

              tmpCol := CreateColumn(Bands[0]);

              tmpCol.Name := tmpcxTreeList.Name + tmpnodes[1].item[k].attributes.item[l].nodeName;

              tmpCol.Position.BandIndex := 0;

              tmpCol.Width := 100;

              tmpCol.Caption.AlignHorz := taCenter;

              tmpCol.Caption.Text := tmpnodes[1].item[k].attributes.item[l].nodeName;

            except

              Bands[0].Columns[ColumnCount-1].Free;

            end;

          End;

        End;

      End;

    End;


    SetLength(tmpvalues,tmpcxTreeList.ColumnCount);


    For i := 0 To attributes.length -1 Do//form att

    Begin

      tmpvalues[i] := attributes.item[i].Text;

    End;


    For i := 0 To nodes.length - 1 Do

    Begin

      For j := 0 To nodes.item[i].attributes.length -1 Do//man att

      Begin

        tmpvalues[j+attributes.length] := nodes.item[i].attributes.item[j].Text;

      End;

      For j := 0 To nodes.item[i].childNodes.length - 1 Do

      Begin

        tmpnodes[0] := nodes.item[i].childNodes;

        For k := 0 To tmpnodes[0].item[j].attributes.length -1 Do//data att

        Begin

          tmpvalues[k+attributes.length + nodes.item[i].attributes.length]

           := tmpnodes[0].item[j].attributes.item[k].Text;

        End; {

        For k := 0 To tmpnodes[0].item[j].childNodes.length - 1 Do

        Begin

          tmpnodes[1] := tmpnodes[0].item[j].childNodes;


          tmpvalues[k+attributes.length + nodes.item[i].attributes.length +

                        tmpnodes[0].item[j].attributes.length]

           := tmpnodes[1].item[k].Text;


          For l := 0 To tmpnodes[1].item[k].attributes.length -1 Do//amt att

          Begin

            tmpvalues[k+attributes.length + nodes.item[i].attributes.length +

                          tmpnodes[0].item[j].attributes.length + l + 1]

             := tmpnodes[1].item[k].attributes.item[l].Text;

             //amt 반복 처리.ㅡ 여기서 포기

          End;

        End; }

        tmpNode := Add;

        for m := 0 to Length(tmpvalues) - 1 do

        begin

          tmpNode.Texts[m] := tmpvalues[m];

        end;

      End;

    End;

    EndUpdate;

  end;

end;



'델파이' 카테고리의 다른 글

델파이 푸시  (0) 2015.10.15
FTP 파일 전송  (0) 2015.09.14
클래스명 string으로 해당 클래스 호출하기  (0) 2015.09.08
Posted by newkie