databricks / spark-xml

XML data source for Spark SQL and DataFrames
Apache License 2.0
500 stars 226 forks source link

Write an xml element value with escape characters as it is in the input text #611

Closed DipeshV closed 1 year ago

DipeshV commented 1 year ago

Hello,

I am using this connector to write the data to the xml format as below

Dipesh Vora •pim_mandatory_Action_string_mv:Antall stangdeler¶•pim_mandatory

But after the write operation is finished, i get the xml content like below,

Dipesh Vora •pim_mandatory_Action_string_mv:Antall stangdeler¶•pim_mandatory

It is replacing & with & as I think is is escaping the '&' char.

Is there any configuration or wprk around available which can help me to write it without escaping the special characters.

srowen commented 1 year ago

I don't understand what you mean. This is text in an element? those special chars should be escaped in XML; they appear to be not even single-byte chars

DipeshV commented 1 year ago

So when the text in xml is something like A & B, it is written as A & B. I don't need it that way and so it should just write it from dataframe as A & B.

srowen commented 1 year ago

But it has to be written this way in XML to be valid XML

DipeshV commented 1 year ago

I tried many examples with online validators and it gives me valid xml,

I just need to write the texts strictly in this format only.

Can you please suggest me how to do it ?

srowen commented 1 year ago

I don't think so, it's simply invalid output, so there is not a general use case for it