Witold
Databricks Partner

Then your example XML is invalid, as an XML file has only one root element. Meaning, Message can only be there once. If Message is your row, then there needs to be another root element, e.g:

<Messages>
<Message>
<Attribute>1</Attribute>
<Attribute>2</Attribute>
</Message>
</Messages>

 

peter_ticker
New Contributor III

I'm not sure what your concern is. I could've encapsulated the whole thing in another root element but we receive XML files with one row per file so there is no need for a root element.

Witold
Databricks Partner

Let me rephrase it. You can't use Message as the rowTag, because it's the root element. rowTag implies that it's a tag within the root element, which might occur multiple times. Check the docs around reading and write XML files, there you'll find examples which include a root tag (books) and row tags (book). If you check on this page the docs of from_xml, you'll see that "rowTag option is not applicable" due the exact same reason: You read just a single record.

To solve your issue, you either need to introduce another root tag (which I read is not an option for you), or to find another row tag, which might be Attribute. I hope it helps!