# `Lather.Soap.Elements`
[🔗](https://github.com/awksedgreep/lather/blob/v1.1.0/lib/lather/soap/elements.ex#L1)

Prefix-agnostic access to parsed SOAP documents.

`Lather.Xml.Parser` keeps namespace prefixes in element names, so the
same envelope can arrive as `"soap:Envelope"`, `"soapenv:Envelope"`,
`"SOAP-ENV:Envelope"`, `"s:Envelope"` or plain `"Envelope"` depending on
the peer. The functions here look elements up by *local name* so callers
do not have to enumerate prefixes.

# `find`

```elixir
@spec find(any(), String.t()) :: {String.t(), any()} | nil
```

Finds the child of `map` whose local name is `local`.

Returns `{key, value}` with the *actual* (possibly prefixed) key, or
`nil` when there is no such child or `map` is not a map. An exact key
match wins over a prefixed one; attribute keys (`@...`) and `#text` are
never matched.

# `get`

```elixir
@spec get(any(), String.t()) :: any()
```

Returns the value of the child of `map` with local name `local`, or
`nil`.

# `get_in`

```elixir
@spec get_in(any(), [String.t()]) :: any()
```

Walks a path of local names, like `get_in/2` but prefix-agnostic and
safe against non-map intermediate values.

    Elements.get_in(parsed, ["Envelope", "Body", "Fault"])

# `local_name`

```elixir
@spec local_name(String.t() | atom()) :: String.t()
```

Returns the local part of a possibly prefixed element name.

    iex> Lather.Soap.Elements.local_name("soapenv:Body")
    "Body"
    iex> Lather.Soap.Elements.local_name("Body")
    "Body"

# `namespace_of`

```elixir
@spec namespace_of(String.t(), any()) :: String.t() | nil
```

Returns the namespace URI declared for `element_key`'s prefix on
`element` (a parsed element map), or `nil`.

Looks for `@xmlns:prefix` when the key is prefixed and `@xmlns` when it
is not.

# `prefix`

```elixir
@spec prefix(String.t() | atom()) :: String.t() | nil
```

Returns the prefix of an element name, or `nil` when it has none.

# `soap_1_1_namespace`

SOAP 1.1 envelope namespace URI.

# `soap_1_2_namespace`

SOAP 1.2 envelope namespace URI.

# `soap_version`

```elixir
@spec soap_version(map()) :: :v1_1 | :v1_2
```

Detects the SOAP version of a parsed document from the namespace bound
to the Envelope element. Falls back to the fault structure (SOAP 1.2
faults carry `Code/Value`) and finally to `:v1_1`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
