Re: [xml] Document comments



Daniel Veillard wrote:

  xmlAddChild((xmlNodePtr) doc, comment)
those kind of operations work on the common part of the node structures.

Is this an officially endorsed practice? I mainly ask, because I feel
reluctant about casting between two conceptually different structs.

doc.addChild(comment)
[...]
root.addPrevSibling(comment)

I got both to work by upgrading to the latest libxml2 version.
Sorry about that.

   xmlDocSetRootElement() is more expected to be used for elements nodes
for example it will wipe out the old root if it already exists.

I fail to see the purpose of xmlNewDocComment() then.

  I don't see the link between your sentence and mine ...

Well, at the time of writing, the only possibility I could see
for adding a document comment was to use xmlDocSetRootElement().
If that function only was intended to set the actual root element,
and not to add document comments as well, then I had difficulty
understanding why xmlNewDocComment() was needed at all. That is,
why have a special function for this, rather than just using
xmlNewComment()? I guess, that question is not relevant after
all.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]