I have an xml file with the following values:
<InspectionChecklist>
<InspectionChecklistItem>
<ChecklistItemDescription>Frame damaged</ChecklistItemDescription>
<ChecklistItemValue>1</ChecklistItemValue>
</InspectionChecklistItem>
<InspectionChecklistItem>
<ChecklistItemDescription>Smokers Flag</ChecklistItemDescription>
<ChecklistItemValue>1</ChecklistItemValue>
</InspectionChecklistItem>
</InspectionChecklist>
And I want the result to look like
<FrameDamage>Y</FrameDamage>
<SmokerFlag>Y</SmokerFlag>
So, in the original xml, it is possible that I will not have any ChecklistItemDescription or other descriptions of the elements of the checklist, such as -
Example 1 -
Source
<InspectionChecklist></InspectionChecklist>
I want the result to look like
<FrameDamage>N</FrameDamage>
<SmokerFlag>N</SmokerFlag>
Example 2 -
Source
<InspectionChecklist>
<InspectionChecklistItem>
<ChecklistItemDescription>Airbag Light</ChecklistItemDescription>
<ChecklistItemValue>1</ChecklistItemValue>
</InspectionChecklistItem>
<InspectionChecklistItem>
<ChecklistItemDescription>Smokers Flag</ChecklistItemDescription>
<ChecklistItemValue>1</ChecklistItemValue>
</InspectionChecklistItem>
</InspectionChecklist>
The result should look like this:
<FrameDamage>N</FrameDamage>
<SmokerFlag>Y</SmokerFlag>
I have done several ways and can make individual ones work. But I can not get them to work for every possible occasion.
Any help would be appreciated.
source
share