Closed jzakrzewski closed 9 months ago
@jzakrzewski I know this is old, but if you still got code that reproduces this, that would be great. It sure sounds like an omission on my part.
Hi @jzakrzewski @lestrrat Maybe it will help to solve this issue or to fix it. I've got the same problem when I tried to walk over nodes panic: interface conversion: *dom.Text not types.Element: missing method AppendText But I've noticed that in test the same method worked. The difference is a content of xml files Walking through this one works fine:
<?xml version="1.0" encoding="UTF-8"?><Data xmlns="http://www.example.com/OTA/2003/05"><Dates start='1987-01-12'/></Data>
This xml causes panic:
<?xml version="1.0" encoding="UTF-8"?>
<Data xmlns="http://www.example.com/OTA/2003/05">
<Dates start='1987-01-12'/>
</Data>
This helped me XMLParseNoBlanks
d, err := libxml2.ParseString(s, parser.XMLParseNoBlanks)
Or replace new lines and spaces between nodes but it is not an elegant solution.
@lestrrat damn! I've missed your comment somehow... I'm not sure if I have it. I guess I have implemented something else instead. But yeah, I can check what was it all about.
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity. This does not mean your issue is rejected, but rather it is done to hide it from the view of the maintains for the time being. Feel free to reopen if you have new comments
I tried to Walk all the nodes of a Document starting from root, print all node names, and attributes for the Element nodes. There's however a problem:
panics at runtime with
panic: interface conversion: *dom.XMLNode is not types.Element: missing method AppendText
. I've also triede := n.(*dom.Element)
only to getpanic: interface conversion: types.Node is *dom.XMLNode, not *dom.Element
.I've debugged a bit and it seems that the receiver gets converted to
*dom.XMLNode
because of the Walk method receiver type. I can work this around by callingdoc.Walk...
but it won't work if I wanted to start from an arbitrary node.Sorry I won't fix it myself but I've just started with go and I don't feel like I could do it right.