JuliaIO / LightXML.jl

A light-weight Julia package for XML based on libxml2.
MIT License
90 stars 39 forks source link

is it possible to make copy of element? #119

Closed PharmCat closed 2 years ago

PharmCat commented 2 years ago

I try to copy some elements from one xml to another:

#source
xdoc = parse_file("test.xml")
odm = LightXML.root(xdoc)
st = LightXML.find_element(odm, "Study")

#destination
xd = XMLDocument()
e = create_root(xd, "Study")
elm = collect(LightXML.child_elements(st));

# this remove from source to destination
dc = deepcopy(elm[4])
unlink(dc)
add_child(e, dc)

#this copy all elements to xd ???  why ?
add_child(e, elm[4])

#this copy all elements to xd  too
add_child(e, deepcopy(elm[4]))