I have an xml file with the tag data from Stackexchange: https://archive.org/download/stackexchange/stackoverflow.com-Tags.7z

After I unzip it I would like to import it to Mathematica to some statistics. I get an XML Object like this:

  "Document"][{XMLObject["Declaration"]["Version" -> "1.0", 
   "Encoding" -> "utf-8"]}, 
  "tags", {}, {XMLElement[
    "row", {"Id" -> "1", "TagName" -> ".net", "Count" -> "265332", 
     "ExcerptPostId" -> "3624959", "WikiPostId" -> "3607476"}, {}], 
    "row", {"Id" -> "2", "TagName" -> "html", "Count" -> "733157", 
     "ExcerptPostId" -> "3673183", "WikiPostId" -> "3673182"}, {}]

How do i convert it to a Mathematica dataset?

I'm aware that a similar question was asked regarding Import itunes xml data. (Import iTunes xml data and convert it into a dataset or table) but i could not figure out how to change this code that i can use it for my XML Object.

Some help would be highly appreciated!

  • 3
    $\begingroup$ For the snippet you showed Dataset@Cases[xml, XMLElement[_, attrs_, _]:>Association[attr], Infinity] should work $\endgroup$
    – b3m2a1
    Mar 27, 2018 at 17:35
  • $\begingroup$ @b3m2a1 thank you very much!! It worked perfect. $\endgroup$ Mar 28, 2018 at 11:24


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.