Re: [xml] create node from a string (with xml elements inside)



Hello again,

I did it with parsing a doc in memory like

        const char * xml = "<mycontent><mytext>hello</mytext></mycontent>";
        xmlDocPtr doc_fragment = xmlReadMemory(xml, strlen(xml),"noname.xml",NULL,0);
        xmlNodePtr root_node = 	xmlDocGetRootElement(doc_fragment);
        xmlNodePtr new_node = xmlDocCopyNode (root_node, doc, 1);
        xmlFreeDoc(doc_fragment);

        xmlAddChild(mynodewhereIwanttoinsertthisfragment,new_node);

and it works!

is it the best solution? (only one?)

Best regards,
Sylvain


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