libxml2 can´t get content from node

前端 未结 1 898
一生所求
一生所求 2021-02-20 13:44

I am using libxml in C and this is how I create xml:

xmlDocPtr createXmlSegment(char *headerContent, char *dataContent)
{
  xmlDocPtr doc;
  doc = xmlNewDoc(BAD_         


        
相关标签:
1条回答
  • 2021-02-20 14:37

    Short answer: use xmlNodeGetContent.

    Element nodes themselves don't contain content. Instead, they have children text nodes, and those contain content. The contents of an element may be a mix of text and tags, and this allows it to maintain the ordering, represent entities, etc.

    You could iterate over the child nodes and look at THEIR content members, but xmlNodeGetContent does that for you, and will handle child tags and entities properly.

    0 讨论(0)
提交回复
热议问题