I can't see what I'm doing wrong in the following - I'd like to import some XML as a Tree (for structure visualisation) and convert it to an Association for querying content:
xtree = ExpressionTree[Import["ExampleData/paintings.xml"], "XML"]
Which appears to work as it should.
I then use TreeExpression to obtain an Association but I get a nested list:
TreeExpression[xtree, "Association"]
Which returns this nested list and not an Association:
{{{"Version" -> "1.0",
"Encoding" -> "ISO8859-1"}}, {{{"No.5, 1948"}, {"Jackson Pollock"}, {"1948"}, \
{"$140,000,000"}}, {{"Woman III"}, {"Willem de Kooning"}, {"1953"}, \
{"$137,500,000"}}, {{"Portrait of Adele Block-Bauer I"}, {"Gustav \
Klimt"}, {"1907"}, {"$135,000,000"}}, {{"Portrait of Dr. Gachet"}, \
{"Vincent van Gogh"}, {"1890"}, {"$82,500,000"}}, {{"Bal au moulin de \
la Galette, Montmartre"}, {"Pierre-Auguste Renoir"}, {"1876"}, \
{"$78,100,000"}}}, {}}
I've tried various options (e.g. Heads-> True makes no difference). Any suggestions?
$VersionNumber
14.


"Association"works only if the tree is already represented with associations, for example:TreeExpression[Tree[Null, <|a -> Tree[1, None], b -> Tree[Null, <|c -> Tree[2, None]|>]|>], "Association"], which yours is not (check theInputForm). For general instructions regarding XML, you can read XML Capabilities Tutorial. – Domen Jan 29 '24 at 15:09