[xml] how to change value of an attribute not attached to element



Hello,

what is the best way to set attribute value when the attribute itself is not
yet attached to any element node ?

I need this to correctly implement DOM wrapper for libxml2 - DOM enables to
create attribute node and handle it independently of its carrying element
just as any other node.

I was experimenting with various functions from tree.h, but without success
(xmlSetProp needs parent element). I know I can do this by copy/pasting some
code from tree.c, which assigns the value to an attribute, but I prefer not
to depend so much on libxml2 internals.

If  it is not currently possible, I suggest to add this possibility to the
xmlNodeSetContent() function, which currently does nothing with attribute
nodes.
(I hope it is a correct place, because xmlNodeGetContent() explicitly
handles XML_ATTRIBUTE_NODE)

Thanks,
Petr




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