Ниже приведен пример XML, где атрибут «Значение» является пустым в разделе «Дополнительный атрибут». Как я могу удалить этот атрибут при записи в XML в pyspark. Я хочу удалить только если атрибут пуст.
<ItemList>
<Item Action="MANAGE" ItemGroupCode="PROD" ItemID="Item1" OrganizationCode="" UnitOfMeasure="EACH">
<PrimaryInformation Description="Item1" ItemType="WEB" ProductLine="GM" IsPickupAllowed="Y" IsReturnable="Y" IsShippingAllowed="Y" ShortDescription="Item1:Black:Medium" IsModelItem="N" ModelItemUnitOfMeasure="EACH" ImageLocation="" ImageID=""></PrimaryInformation>
<ItemAliasList Reset="Y"></ItemAliasList>
<Extn ExtnColor="BLACK" ExtnColorDesc=""></Extn>
<ClassificationCodes Model="Item1"></ClassificationCodes>
<AdditionalAttributeList Reset="Y">
<AdditionalAttribute AttributeDomainID="ItemAttribute" AttributeGroupID="ItemAttributeGroup1" Name="Size" Value=""></AdditionalAttribute>
<AdditionalAttribute AttributeDomainID="ItemAttribute" AttributeGroupID="ItemAttributeGroup1" Name="Color" Value=""></AdditionalAttribute>
</AdditionalAttributeList>
</Item>
</ItemList>
I tried with setting treatEmptyValuesAsNulls to true while writing. But it doesn't work.
df.write \
.format('xml') \
.options(rowTag='Item', rootTag='ItemList', treatEmptyValuesAsNulls = 'true') \
.save(path)
Any kind of help is appreciated.