diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-04-22 14:27:54 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-04-22 14:27:54 +0600 |
commit | 3b2b0d009ba7962da8b12c62f119fa4b1178e858 (patch) | |
tree | 7ba33984c0022a875197a8c9d1bcd921c0a1415a /src | |
parent | 79d3355b943f077b5e864177e1f14fbed3454cf9 (diff) | |
download | vyconf-3b2b0d009ba7962da8b12c62f119fa4b1178e858.tar.gz vyconf-3b2b0d009ba7962da8b12c62f119fa4b1178e858.zip |
Add a function for looking up xml-light tag children.
It now lives in a Util, a module that implements the adopter design pattern.
Diffstat (limited to 'src')
-rw-r--r-- | src/util.ml | 11 | ||||
-rw-r--r-- | src/util.mli | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/util.ml b/src/util.ml new file mode 100644 index 0000000..33c90a2 --- /dev/null +++ b/src/util.ml @@ -0,0 +1,11 @@ +(* Unavoidable module for functions that don't fit anywhere else *) + +let find_xml_child name xml = + let find_aux e = + match e with + | Xml.Element (name', _, _) when name' = name -> true + | _ -> false + in + match xml with + | Xml.Element (_, _, children) -> List.find find_aux children + | Xml.PCData _ -> raise Not_found diff --git a/src/util.mli b/src/util.mli new file mode 100644 index 0000000..e4ced4f --- /dev/null +++ b/src/util.mli @@ -0,0 +1 @@ +val find_xml_child : string -> Xml.xml -> Xml.xml |