How to add a xml node constructed from string in libxml2

后端 未结 4 598
栀梦
栀梦 2021-02-09 13:34

I am using Libxml2 for encoding the data in a xml file. My data contain tags like \"<\" and \">\". when it is converted into xml these tags are also converted into \"<\

4条回答
  •  不知归路
    2021-02-09 13:46

    You have to call xmlNewChild in a chain, one call for the parent node and a call each for each sub-node:

    xmlNodePtr *addressNode = xmlNewChild(node, NULL, (xmlChar *) "address", NULL);
    xmlNewChild(addressNode, NULL, (xmlChar *) "street", "Park Street");
    xmlNewChild(addressNode, NULL, (xmlChar *) "city", "Koltaka");
    

提交回复
热议问题