aboutsummaryrefslogtreecommitdiff
path: root/src/xml.erl
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2003-01-02 21:01:12 +0000
committerAlexey Shchepin <alexey@process-one.net>2003-01-02 21:01:12 +0000
commit44797c9524663c38600743ce3947d80472c849ae (patch)
treeaa710dfb3c7c36615ba214320ee065a0cc1d6fff /src/xml.erl
parent*** empty log message *** (diff)
*** empty log message ***
SVN Revision: 25
Diffstat (limited to 'src/xml.erl')
-rw-r--r--src/xml.erl33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/xml.erl b/src/xml.erl
index 171607361..00b7087d5 100644
--- a/src/xml.erl
+++ b/src/xml.erl
@@ -13,7 +13,9 @@
-export([element_to_string/1, crypt/1, remove_cdata/1,
get_cdata/1, get_tag_cdata/1,
get_attr/2, get_attr_s/2,
- get_tag_attr/2, get_tag_attr_s/2]).
+ get_tag_attr/2, get_tag_attr_s/2,
+ get_subtag/2,
+ get_path_s/2]).
element_to_string(El) ->
case El of
@@ -100,3 +102,32 @@ get_tag_attr(AttrName, {xmlelement, Name, Attrs, Els}) ->
get_tag_attr_s(AttrName, {xmlelement, Name, Attrs, Els}) ->
get_attr_s(AttrName, Attrs).
+
+get_subtag({xmlelement, _, _, Els}, Name) ->
+ get_subtag1(Els, Name).
+
+get_subtag1([El | Els], Name) ->
+ case El of
+ {xmlelement, Name, _, _} ->
+ El;
+ _ ->
+ get_subtag1(Els, Name)
+ end;
+get_subtag1([], _) ->
+ false.
+
+
+get_path_s(El, []) ->
+ El;
+get_path_s(El, [{elem, Name} | Path]) ->
+ case get_subtag(El, Name) of
+ false ->
+ "";
+ SubEl ->
+ get_path_s(SubEl, Path)
+ end;
+get_path_s(El, [{attr, Name}]) ->
+ get_tag_attr_s(Name, El);
+get_path_s(El, [cdata]) ->
+ get_tag_cdata(El).
+