Can "item" of ArrayType be renamed via an option when writing an XML file?
See original GitHub issueI am writing the XML file below and would like to know how I can rename “item” with “record” (since those items are within the “records” tag). Perhaps there is a way to change the value “item” in here.
<?xml version="1.0" encoding="UTF-8"?>
<inventory xmlns="http://www.domain.com/xml/">
<inventory-list>
<header list-id="myShop">
<default>false</default>
</header>
<records>
<item product-id="xxxxxx-yyy1">
<qty>0</qty>
</item>
<item product-id="xxxxxx-yyy2">
<qty>0</qty>
</item>
<item product-id="xxxxxx-yyy3">
<qty>0</qty>
</item>
<item product-id="xxxxxx-yyy4">
<qty>0</qty>
</item>
<item product-id="xxxxxx-yyy5">
<qty>0</qty>
</item>
</records>
</inventory-list>
</inventory>
Here is the schema of my dataframe:
root
|-- header: struct (nullable = true)
| |-- _list-id: string (nullable = true)
| |-- default: boolean (nullable = true)
|-- records: array (nullable = false)
| |-- element: array (containsNull = false)
| | |-- element: struct (containsNull = false)
| | | |-- _product-id: string (nullable = true)
| | | |-- qty: integer (nullable = true)
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
Controlling XML Serialization Using Attributes - Microsoft Learn
Attributes can be used to control the XML serialization of an object or to create an alternate XML stream from the same set...
Read more >Controlling the XML Element and Attribute Names
In an XML-enabled object, an array-type property is projected to an element with subelements, each of which is one item in that array,...
Read more >How to split a spark dataframe column of ArrayType ...
I am reading xml using databricks spark xml with ...
Read more >Spark Read XML file using Databricks API
In this article, I will explain how to read XML file with several options using the Scala example. Spark XML Databricks dependency; Spark...
Read more >Example: Parsing an XML Document Using a Scalar UDF
15.00 - Example: Parsing an XML Document Using a Scalar UDF - Teradata Database. Teradata Database SQL Data Definition Language Syntax and Examples....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sure, in Databricks you can just attach a JAR file to a cluster. You just need to build a JAR file – one including all dependencies – from the project. Check out the code and run
sbt assembly
and you should find the JAR intarget/scala-2.12/spark-xml-assembly-0.16.0.jar
. When it’s released you’d also be able to just add it by Maven coordinates rather than build ithttps://github.com/databricks/spark-xml/pull/603