Below is our Source
Code: Select all
REFERENCE MODELCODE OPTIONCODE Acc1 Acc2
AUDA11001 8X1AA4 4025100 YES-A-B YES-1-2
AUDA11002 8X1ABC 4025200 NO-C-D YES-3-4
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<body>
<vehicle>
<specifications>
<REFERENCE>AUDA11001</REFERENCE>
<MODELCODE>8X1AA4</MODELCODE>
<OPTIONCODE>4025100</OPTIONCODE>
</specifications>
<accessory>
<id>YES</id>
<name>A</name>
<type>B</type>
</accessory>
<accessory>
<id>YES</id>
<name>1</name>
<type>2</type>
</accessory>
<specifications>
<REFERENCE>AUDA11002</REFERENCE>
<MODELCODE>8X1ABC</MODELCODE>
<OPTIONCODE>4025200</OPTIONCODE>
</specifications>
<accessory>
<id>YES</id>
<name>3</name>
<type>4</type>
</accessory>
</vehicle>
</body>
As we can see first 3 fields (REFERENCE,MODELCODE,OPTIONCODE) goes under specifications which occurs once for each record
and is followed accessory Element which is repeated and each of Acc1 and Acc2 must be created for each record as shown under <accessory>
Trickish part here is , in the fileds Acc1 and Acc2, If the First portion of the value before '-' is "NO" Then that elemnet must not be created
For example, for the second record , we will not create Acc1, but create only Acc2 as shown below
Code: Select all
<accessory>
<id>YES</id>
<name>3</name>
<type>4</type>
</accessory>
PS, this is sample example and in the actual file we have around 10 accessories ( till Acc10 ) that must be created for each record
Regards
Aj