Re: [xml] Use of the "&" character in the content of a Node



* A. Pagaltzis <pagaltzis gmx de> [2006-05-18 18:10]:
 nodePtr = xmlNewNode(NULL, "node");
 if (nodePtr)
 {
   xmlNodeSetContent(nodePtr, "111&222");
 }


    nodePtr = xmlNewNode(NULL, "node");
    if (nodePtr)
    {
        xmlNodeAddContent(nodePtr, "111&222");
    }

Err, theyâre probably both equally wrong. I *think* you want
this:

    nodePtr = xmlNewNode(NULL, "node");
    textPtr = xmlNewText("111&222");
    if (nodePtr && textPtr)
    {
        xmlAddChild(nodePtr, textPtr);
    }

But I canât check right now.

In any case, the correct solution will take the string "111&222"
and automatically put the properly escaped "111&amp;222" into the
text node.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



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