question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can "item" of ArrayType be renamed via an option when writing an XML file?

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
srowencommented, Sep 5, 2022

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 in target/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 it

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found