-3

I have this XML. I know how to read "EDI_DC40" and get values.

<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</KTEXT>
    </E1EDP19>
  </E2EDP01008GRP>
  <E2EDP01008GRP>
    <E1EDP01>
      <POSEX>00001</POSEX>
      <MENGE>1000.000</MENGE>
      <MENEE>PCE</MENEE>
      <VPREI>2.24</VPREI>
      <PEINH>200</PEINH>
      <NETWR>1.4</NETWR>
    </E1EDP01>
    <E1EDP20>
      <WMENG>200.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>

But i don't know how to read "E2EDP01008GRP" and value inside "POSEX", especially if there are two nodes of the same name. Can anyone point me to right direction or show me in code?

Charles
  • 50,943
  • 13
  • 104
  • 142
user2997342
  • 87
  • 2
  • 3
  • 8
  • you just read node #1, then you read node #2 then you read node #3, etc. If they woulf be named or not - does not matter. You can enumerate them like this: https://superobject.googlecode.com/git/readme.html after using XML loader https://superobject.googlecode.com/git/ – Arioch 'The Nov 21 '13 at 11:28

2 Answers2

4

Since you mentioned the usage of IXMLDocument in your last question regading this document, an example implementation could look like this:

var
  DOC:IXMLDocument;
  i: Integer;
  OrderChilds, E1EDP01_Node: IXMLNode;
begin
  DOC := LoadXMLDocument('c:\temp\orders.xml');
  // iterate your root node 'OREDERS'
  for i := 0 to DOC.ChildNodes.Nodes['ORDERS'].ChildNodes.Count - 1 do
  begin
    OrderChilds := DOC.ChildNodes.Nodes['ORDERS'].ChildNodes[i];
    if OrderChilds.NodeName = 'E2EDP01008GRP' then  // Your node(s) of interest
    begin
      E1EDP01_Node := OrderChilds.ChildNodes.Nodes['E1EDP01'];
      if Assigned(E1EDP01_Node) then // did we find the node keeping the 'POSEX' node
        Memo1.Lines.Add(E1EDP01_Node.ChildNodes.Nodes['POSEX'].NodeValue)
    end;
  end;
end;
bummi
  • 27,123
  • 14
  • 62
  • 101
2

You just read node #1, then you read node #2 then you read node #3, etc. If they would have the same names or not - does not matter. Just read them one after another.

You can enumerate them like this: superobject.googlecode.com/git/readme.html after using XML loader superobject.googlecode.com/git

Or you can take any other XML parser.

et cetera

You may also try some EDI-targeted library like http://edisdk.sourceforge.net/index.htm that was later merged into Jedi Code Library (but could be was abandoned and removed later)

Community
  • 1
  • 1
Arioch 'The
  • 15,799
  • 35
  • 62