How to read Siblings in an XML file by NAvision ?

subhaster
subhaster Member Posts: 64
Hi,
I am using an XML file , which contains an <Variants> containing siblings.
It looks like as follows :-
<Item>
   <Variants>
    <Variant>
     <code>c1</code>
     <desc>d1</desc>
    </Variant>
    <Variant>
     <code>c2</code>
     <desc>d2</desc>
    </Variant>
  </variants>
  </Item>
Can any one tell me , how in Navision , I am going to parse such repititive bodies/siblings ?
Subhasish Chakraborty,
Systems Analyst,
MBS Dynamics.

Comments

  • DenSter
    DenSter Member Posts: 8,307
    Sure, create an XMLPort and indent the elements the way you need them. Once you look at one of the existing ones, you'll see how to do that.
  • subhaster
    subhaster Member Posts: 64
    Thanks soooo much Den !
    :D
    I solved it like this :-
    XMLNodeList := XmlDom.getElementsByTagName('Item/Variants/Variant');
    XMLRootNode := XMLNodeList.item(0);
    WHILE NOT ISCLEAR(XMLRootNode) DO BEGIN
      vVariantCode := XMLRootNode.selectNodes('Code').item(0).text;
      Desc1 := XMLRootNode.selectNodes('Description').item(0).text;
      Desc2 := XMLRootNode.selectNodes('Description2').item(0).text;
      ItemVariants."Item No.":=VItemNo;
      ItemVariants.Code:=vVariantCode;
      ItemVariants.Description:=Desc1;
      ItemVariants."Description 2":=Desc2;
      ItemVariants.INSERT(TRUE);
      XMLRootNode := XMLNodeList.nextNode;
    END;
    

    The above code extracts item variants from an XML file containing informations regarding an item creation.
    Subhasish Chakraborty,
    Systems Analyst,
    MBS Dynamics.