Parsing slightly complex XML using Sweet_XML

I have some xml that has some complex types that inherit from other complex types. This looks something like:

<complexTypeTwo xsi:type="ns1:ComplexTypeOne">
    <identifier>Two</identifier>
    <some>thing</some>
    <other>stuff</other>
</complextTypeTwo>

I’m having a very hard time getting the xsi:type attribute value using sweet_xml.
Right now I’m trying to have my xml mapped to a struct using

import SweetXml
xml 
|> parse() 
|> xmap(
...
complex_base_type: ~x[./complexTypeTwo/@type]s,
...
)

That isn’t working, and I’m not finding anything in the docs that’s helping.
I’m hoping someone here has already solved this problem, and can point me in the right direction.

1 Like

I’m not certain and my XML is rusty (not that it was ever good), but could it be that you need to include the xsi namespace in your XPath?

~x[./complexTypeTwo/@xsi:type]s

I tried that as well, but no joy.

1 Like