Skip to content

Commit

Permalink
show for Document
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 1, 2020
1 parent eefee4e commit 1cc8cc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ function HTMLDocument(uri=nothing, externalID=nothing)
return Document(node.ptr)
end

function Base.show(io::IO, doc::Document)
prefix = "EzXML.Document"
node = repr(doc.node)
print(io, "$(prefix)($node)")
end

function Base.print(io::IO, doc::Document)
print(io, doc.node)
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ end
@test occursin(r"^Node\(<DOCUMENT_NODE>\)$", repr(doc.node))
@test occursin(r"^Node\(<ELEMENT_NODE\[root\]>\)$", repr(root(doc)))
@test occursin(r"^Node\(<ATTRIBUTE_NODE\[attr\]>\)$", repr(attributes(root(doc))[1]))
@test occursin(r"^EzXML.Document\(Node\(<DOCUMENT_NODE>\)\)$", repr(doc))
@test occursin(r"^Document\(Node\(<DOCUMENT_NODE>\)\)$", repr(doc))

sample2 = joinpath(dirname(@__FILE__), "sample2.xml")
reader = open(EzXML.StreamReader, sample2)
Expand Down

0 comments on commit 1cc8cc7

Please sign in to comment.