delphi导入读取xml

时间:2013-11-15 18:20:43

标签: xml delphi

我是xml和delphi的新手。我有这个xml文件,现在不知道如何读取节点。

    <ns0:ORDERS xmlns:ns0="http://Purchasing/GenericPartner">
  <EDI_DC40>
    <TABNAM>EDI_DC40</TABNAM>
    <MANDT>210</MANDT>
    <DOCNUM>1498177</DOCNUM>
    <DOCREL>700</DOCREL>
    <STATUS>30</STATUS>
    <DIRECT>1</DIRECT>
    <OUTMOD>2</OUTMOD>
    <EXPRSS></EXPRSS>
    <TEST></TEST>
    <IDOCTYP>ORDERS05</IDOCTYP>
    <CIMTYP></CIMTYP>
    <MESTYP>ORDERS</MESTYP>
    <MESCOD></MESCOD>
    <MESFCT>GEN</MESFCT>
    <STD></STD>
    <STDVRS></STDVRS>
    <STDMES>ORDERS</STDMES>
    <SNDPOR>SAPR3D</SNDPOR>
    <SNDPRT>LS</SNDPRT>
    <SNDPFC></SNDPFC>
    <SNDPRN>R3DCLNT210</SNDPRN>
    <SNDSAD></SNDSAD>
    <SNDLAD></SNDLAD>
    <RCVPOR>BT_EDIPURC</RCVPOR>
    <RCVPRT>LI</RCVPRT>
    <RCVPFC>BA</RCVPFC>
    <RCVPRN>0002000007</RCVPRN>
    <RCVSAD></RCVSAD>
    <RCVLAD></RCVLAD>
    <CREDAT>20101124</CREDAT>
    <CRETIM>085946</CRETIM>
    <REFINT></REFINT>
    <REFGRP></REFGRP>
    <REFMES></REFMES>
    <ARCKEY></ARCKEY>
    <SERIAL>20101116202544</SERIAL>
  </EDI_DC40>
  <E1EDK01>
    <CURCY>EUR</CURCY>
    <ZTERM>Z50D</ZTERM>
    <BELNR>4600006935</BELNR>
  </E1EDK01>
  <E1EDK03>
    <IDDAT>012</IDDAT>
    <DATUM>20101116</DATUM>
  </E1EDK03>
  <E1EDKA1>
    <PARVW>AG</PARVW>
    <TELF1>11111</TELF1>
    <TELFX>+111</TELFX>
    <BNAME>mataz</BNAME>
  </E1EDKA1>
  <E1EDKA1>
    <PARVW>WE</PARVW>
    <LIFNR>1000</LIFNR>
    <NAME1>skl</NAME1>
    <NAME2></NAME2>
    <STRAS>ulica skladišča 5</STRAS>
    <STRS2></STRS2>
    <ORT01>novo</ORT01>
    <PSTLZ>1000</PSTLZ>
    <LAND1>AU</LAND1>
  </E1EDKA1>
  <E1EDK17>
    <QUALF>001</QUALF>
    <LKOND>CIP</LKOND>
    <LKTEXT>Novo</LKTEXT>
  </E1EDK17>
  <E2EDP01008GRP>
    <E1EDP01>
      <POSEX>00001</POSEX>
      <MENGE>100.000</MENGE>
      <MENEE>PCE</MENEE>
      <VPREI>1.24</VPREI>
      <PEINH>100</PEINH>
      <NETWR>1.24</NETWR>
    </E1EDP01>
    <E1EDP20>
      <WMENG>100.000</WMENG>
      <EDATU>20101126</EDATU>
    </E1EDP20>
    <E1EDP19>
      <QUALF>001</QUALF>
      <IDTNR>000000000000201853</IDTNR>
      <KTEXT>NA.CIPRINOL TBL A5 RU</KTEXT>
    </E1EDP19>
  </E2EDP01008GRP>
  <E1EDS01>
    <SUMID>002</SUMID>
    <SUMME>1.24</SUMME>
  </E1EDS01>
</ns0:ORDERS>

我用delphi代码

阅读
    procedure TForm1.FormCreate(Sender: TObject);
var
  Doc: IXMLDocument;
  Vehicle: IXMLNode;
begin
  Doc := LoadXMLDocument('c:\temp\orders.xml');
  Vehicle := Doc.DocumentElement;
  edit1.Text := Vehicle.ChildNodes['tabnam'].text;


end;

但是edit1.text为空。如何读取节点值TABNAM或MANDT或其他节点。 。请帮忙。

0 个答案:

没有答案