Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/nodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down