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 '18 at 17:35
  • $\begingroup$ @b3m2a1 thank you very much!! It worked perfect. $\endgroup$ – FreshLearner Mar 28 '18 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.