beevik / etree

parse and generate XML easily in go
BSD 2-Clause "Simplified" License
1.47k stars 175 forks source link

function AddChild bug? #101

Closed LiNing2021 closed 3 years ago

LiNing2021 commented 3 years ago

when I make a new child to add it to a doc like this

doc := etree.NewDocument()
doc.ReadFromFile("abc.xml")

child = `<Kokoku></Kokoku>`
Kokoku := etree.NewDocument()
Kokoku.ReadFromBytes([]byte(child));

cc = Kokoku.Copy()
doc.AddChild(cc)  

The resulting document contains a blank tag “<></>” <><Kokoku></Kokoku></> Is this a BUG?

LiNing2021 commented 3 years ago

sorry。There's no problem. It's my code error.

doc := etree.NewDocument() doc.ReadFromFile("abc.xml")

child = <Kokoku></Kokoku> Kokoku := etree.NewDocument() Kokoku.ReadFromBytes([]byte(child));

cc = Kokoku.Copy() data:=cc.SelectElement("data") doc.AddChild(data)