diff --git a/lib/xml_query.ex b/lib/xml_query.ex index 6fde94d..b3d26a2 100644 --- a/lib/xml_query.ex +++ b/lib/xml_query.ex @@ -63,7 +63,7 @@ defmodule XmlQuery do Finds all elements in an XML document that match `xpath`, returning a list of records. Depending on the given xpath, the type of the record may be different. - ```elixir + ``` elixir iex> xml = ~s| | iex> XmlQuery.all(xml, "//fruit") |> Enum.map(&to_string/1) ["", @@ -83,7 +83,7 @@ defmodule XmlQuery do @doc """ Returns the value of `attr` from the outermost element of `xml`. - ```elixir + ``` elixir iex> xml = ~s| | iex> XmlQuery.attr(xml, :id) "123" @@ -103,13 +103,14 @@ defmodule XmlQuery do @doc """ Finds the first element, attribute, or element text in `xml` that matches `xpath`. - ```elixir + ``` elixir iex> alias XmlQuery, as: Xq iex> xml = \""" ...> ...> ...> \""" iex> %Xq.Element{name: :child, attributes: [%Xq.Attribute{value: ~c"oldest"}]} = Xq.find(xml, "//child") + ``` """ @spec find(xml(), xpath()) :: XmlQuery.Element.t() | XmlQuery.Attribute.t() | XmlQuery.Text.t() | nil @@ -129,7 +130,7 @@ defmodule XmlQuery do Given an xml tuple that has already been created by `:xmerl`, wraps the tuple in an `XmlQuery`-specific struct. - ```elixir + ``` elixir iex> xml = \""" ...> ...> @@ -141,6 +142,7 @@ defmodule XmlQuery do ...> ...> \""" iex> %Xq.Attribute{name: :property, value: ~c"root-value"} = XmlQuery.find(xml, "//root/@property") |> XmlQuery.parse() + ``` """ @spec parse(xml()) :: XmlQuery.Element.t() | XmlQuery.Attribute.t() | XmlQuery.Text.t() @@ -181,7 +183,7 @@ defmodule XmlQuery do @doc """ Returns the text value of `xml`. - ```elixir + ``` elixir iex> xml = "AliceA.Aliceston" iex> XmlQuery.text(xml) "Alice A. Aliceston"