SweetXml - how to get the name of the root element of an XML document?

iex> import SweetXml
iex> "<hello>world</hello>" |> SweetXml.parse() |> xpath(~x"name(/*)"s)
"hello"

Stolen from this GitHub issue response.


Side note: That issue thread, although short, taught me a lot of useful information.

2 Likes