Esempio n. 1
0
/**
 * print_element_names:
 * @a_node: the initial xml node to consider.
 *
 * Prints the names of the all the xml elements
 * that are siblings or children of a given xml node.
 */
static void print_element_names(xmlDocPtr doc, xmlNode * a_node)
{
    xmlNode *cur_node = NULL;

    for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
        if (cur_node->type == XML_ELEMENT_NODE) {
            printf("node type: Element, name: %s\n", cur_node->name);
        } else if (XML_TEXT_NODE == cur_node->type) {
            xmlChar *key;
            //key = xmlNodeListGetString(doc, cur_node, 1);
            key = xmlNodeListGetRawString(doc, cur_node, 1);
            printf("text node: %s\n", key);
            xmlFree(key);
        }

        print_element_names(doc, cur_node->children);
    }
}
Esempio n. 2
-1
std::string SXmlNode::GetNodeListString(SXmlDocument& doc)
{
	if(!_node)
		return "";
	if (!doc._doc)
		return "";
	xmlChar * str = xmlNodeListGetRawString(doc._doc, _node, 1);
	if(str){
		std::string result((char*)str);
		xmlFree(str);
		return result;
	}else{
		return "";
	}
}