decode : String -> Result String Xml.Value
Try to decode a string and turn it into an XML value
import Xml exposing(Value(..))
import Xml.Encode exposing (null)
import Dict
decode "<name></name>"
--> Ok (Object [Tag "name" Dict.empty null])
decodeWith : DecodeSettings -> String -> Result String Xml.Value
Try to decode a string and turn it into an XML value
import Xml exposing(Value(..))
import Xml.Encode exposing (null)
import Dict
decode "<name></name>"
--> Ok (Object [Tag "name" Dict.empty null])
{ nullValues : List String
, trueValues : List String
, falseValues : List String
, parseNumbers : Basics.Bool
}
Settings used by decodeWith
.
The *Values
fields define lists of possible values for the
respecitve node types, e.g. ["true", "True"]
for True
.
parseNumbers
specifies if numbers are parsed to
IntNode
/FloatNode
or just StrNode
.
defaultDecodeSettings : DecodeSettings
Good default settings for DecodeSettings
.
decodeInt : String -> Result String Xml.Value
Decode an int
import Xml exposing (Value(..))
decodeInt "hello"
--> Err "could not convert string 'hello' to an Int"
decodeInt "5"
--> Ok (IntNode 5)
decodeFloat : String -> Result String Xml.Value
Decode a float
import Xml exposing (Value(..))
decodeFloat "hello"
--> Err "could not convert string 'hello' to a Float"
decodeFloat "5"
--> Ok (FloatNode 5.0)
decodeFloat "5.5"
--> Ok (FloatNode 5.5)
decodeString : String -> Result String Xml.Value
Decode a string
import Xml exposing (Value(..))
decodeString "hello"
--> Ok (StrNode "hello")
decodeString "hello & good bye"
--> Ok (StrNode "hello & good bye")
decodeBool : String -> Result String Xml.Value
Decode a bool
decodeChildren : DecodeSettings -> String -> Result String Xml.Value
Decode children from a string
import Dict
import Xml exposing (Value(..))
decodeChildren defaultDecodeSettings "<name>hello</name>"
--> Ok (Object [Tag "name" Dict.empty (StrNode "hello")] )
decodeBoolWith : DecodeSettings -> String -> Result String Xml.Value
Decode a bool with settings
decodeFloatWith : DecodeSettings -> String -> Result String Xml.Value
Decode a float with settings
decodeIntWith : DecodeSettings -> String -> Result String Xml.Value
Decode an int with settings
decodeNull : DecodeSettings -> String -> Result String Xml.Value
Decode a null