I have an XML data generated via Javascript in MarkLogic:
<Activities datatype="array">
<Activity>
<ActivityCrewSize>10</ActivityCrewSize>
<ActivitySeqNo>1</ActivitySeqNo>
<ActivityDesc/>
</Activity>
</Activities>
How can I remove the datatype information so it will just look like this:
<Activities>
<Activity>
<ActivityCrewSize>10</ActivityCrewSize>
<ActivitySeqNo>1</ActivitySeqNo>
<ActivityDesc/>
</Activity>
</Activities>
obj.Activities = [];
let act = {
'$type': 'Activity',
'$version': '0.0.1',
}
for (const item of activities) {
act.ActivityCrewSize = fn.normalizeSpace(hl.elementText(item, "CrewSize", true));
act.ActivitySeqNo = fn.normalizeSpace(hl.elementText(item, "SeqNo", true));
act.ActivityDesc = hl.elementText(item, null, true);
obj.Activities.push(act);
}
return obj;
I was able to remove the data type information by converting the data using the Sequence.from
function in MarkLogic. Hope this may help anyone in the future.