parse XML in a string column in an existing DataFrame and add it as a new column with parsed results in scala

20 Views Asked by At

I have a requirement where I need to process a column in a dataframe containing an XML and also want to keep original columns as it is. Parsed elemnts should be added as new columns in existing dataframe. MyDataframe look like this -

`    +---------+--------------------+
     |id|            xmldata|
    +---------+--------------------+
    |    18284|<?xml version="1....|
    |    18307|<?xml version="1....|
    |    18297|<?xml version="1....|
    |    18282|<?xml version="1....|
     +---------+--------------------+`

I want to expand it with parsed elements from xmldata column `` +---------+--------------------++---------+--------+------+------+------+ |id| xmldata |cust_test|cust_val|Addrl1|Addrl2|Addrl3| +---------+--------+------+------+------+------+------+------++------+---+ | 18284|<?xml version="1....| a| 100| 123| 277| 311| | 18284|<?xml version="1... | b| 200| 176| null| 344| | 18284|<?xml version="1....| c| 300| null| 299| 366| +---------+--------------------++---------+--------+------+------+------+

`` I need dataframe with existing columns and parsed columns

0

There are 0 best solutions below