我有一个通过 MarkLogic 中的 Javascript 生成的 XML 数据:
<Activities datatype="array">
<Activity>
<ActivityCrewSize>10</ActivityCrewSize>
<ActivitySeqNo>1</ActivitySeqNo>
<ActivityDesc/>
</Activity>
</Activities>
如何删除数据类型信息,使其看起来像这样:
<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;