diff --git a/src/document.jl b/src/document.jl index 88a791f..bc32412 100644 --- a/src/document.jl +++ b/src/document.jl @@ -120,3 +120,13 @@ function Base.string(xdoc::XMLDocument; encoding::AbstractString="utf-8") end Base.show(io::IO, xdoc::XMLDocument) = print(io, string(xdoc)) + +function find_element(xdoc::XMLDocument, n::AbstractString) + x = root(xdoc) + find_element(x, n) +end + +function get_elements_by_tagname(xdoc::XMLDocument, n::AbstractString) + x = root(xdoc) + get_elements_by_tagname(x, n) +end diff --git a/src/nodes.jl b/src/nodes.jl index 6e7f8e4..08c68ab 100644 --- a/src/nodes.jl +++ b/src/nodes.jl @@ -283,6 +283,10 @@ function find_element(x::XMLElement, n::AbstractString) return nothing end +function find_element(x, ns::Vector{<:AbstractString}) + foldl(find_element, ns; init = x) +end + function get_elements_by_tagname(x::XMLElement, n::AbstractString) lst = Vector{XMLElement}() for c in child_elements(x)