Re: [xml] Behaviour of xmlNodeAddContent() vs. xmlNodeSetContent()



Hi Daniel,

well, comparing the documentation of both calls
(I've actually done so before asking) doesn't make
that different behaviour *that* obvious.

================================================================
void xmlNodeSetContent (xmlNodePtr cur, const xmlChar * content)

Replace the content of a node.
cur:    the node being modified
content:        the new value of the content
================================================================
================================================================
void xmlNodeAddContent (xmlNodePtr cur,const xmlChar * content)

Append the extra substring to the node content.
cur:    the node being modified
content:        extra content
================================================================

However, a statement of you that both calls behave as intended
is abolutely adequate (and appreciated) for my issue, I'd have
to adjust the application, then.

So, if I got this right, that would mean to
- mandatory pass user input through xmlEncodeEntitiesReentrant()
  (resp. xmlEncodeSpecialChars()) before calling
  xmlNodeSetContent()

- mandatory NOT do so before calling xmlNodeAddContent()
?


Thanks & Ciao, Markus



-----Ursprüngliche Nachricht-----
Von: Daniel Veillard [mailto:veillard redhat com]
Gesendet: Mittwoch, 25. Oktober 2006 13:23
An: Keim, Markus
Cc: xml gnome org
Betreff: Re: [xml] Behaviour of xmlNodeAddContent() vs.
xmlNodeSetContent()


On Wed, Oct 25, 2006 at 11:33:39AM +0200, Keim, Markus wrote:
So, the question: Am I simply wrong in using these calls,
or is it really an issue within libxml2?

  Well I think you're wrong in your expectation that both calls will
work the same way. xmlNodeAddContent really just does a concatenation
at the string level as its documenation implies

   "Append the extra substring to the node content."

while xmlNodeSetContent is more complex trying to process embbeded
entities references.

  Trying to change their behaviour sounds dangerous to me.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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