tags : String -> Xml.Value -> List Xml.Value
Search an XML value for any tags matching
import Xml exposing (Value(..))
import Xml.Encode exposing (object, null, encode)
import Dict
object [ ("name", Dict.empty, null)] |> tags "name"
--> [Tag "name" Dict.empty (Object []) ]
contains : Xml.Value -> Xml.Value -> Basics.Bool
check if a XML value contains another XML value
tag : String -> (Xml.Value -> Result String a) -> Xml.Value -> Result String a
Try to get a given tag name out from an XML value, then grab the value from that Grabs the first tag that matches in the object
import Dict
import Xml exposing (Value(..))
tag "name" string (Tag "name" Dict.empty (StrNode "noah"))
--> Ok "noah"
tag "name" string (Tag "name" Dict.empty (IntNode 5))
--> Err "Not a string."
tag "name" string (StrNode "noah")
--> Err "No tag called 'name' found."
collect : (Xml.Value -> Result String a) -> List Xml.Value -> List a
Collect as many values that pass the given converter
import Dict
import Xml exposing (Value(..))
collect (tag "name" string) [Tag "name" Dict.empty (StrNode "noah")]
--> [ "noah" ]
collect (tag "name" string) [Tag "name" Dict.empty (IntNode 5)]
--> [ ]
default : b -> Result a b -> Result a b
Set a default for a result
>> default "Cat" (Ok "Fish")
Ok "Fish"
>> default "Dog" (Err "flip")
Ok "Dog"
string : Xml.Value -> Result String String
Try to turn a value into a string
import Xml exposing (Value(..))
string (IntNode 5)
--> Err "Not a string."
string (StrNode "hello")
--> Ok "hello"
int : Xml.Value -> Result String Basics.Int
Try to turn a value into an int
import Xml exposing (Value(..))
int (IntNode 5)
--> Ok 5
int (StrNode "hello")
--> Err "Not an int"
float : Xml.Value -> Result String Basics.Float
Try to turn a value into an int
import Xml exposing (Value(..))
float (FloatNode 5.5)
--> Ok 5.5
float (StrNode "hello")
--> Err "Not a float"
bool : Xml.Value -> Result String Basics.Bool
Try to turn a value into an int
import Xml exposing (Value(..))
bool (BoolNode True)
--> Ok True
bool (StrNode "hello")
--> Err "Not a bool"