Beispiel #1
0
int main() {
	char* docname = "web.html";
	xmlDocPtr doc = NULL;
	xmlXPathObjectPtr xpath_obj = NULL;
	xmlNodeSetPtr nodeset = NULL;
	xmlChar* xpath_exp = (xmlChar*)"//pid";
	xmlChar* uri;

	doc = getDocPtr(docname);

	xpath_obj = getXPathObjectPtr(doc, xpath_exp);
	//printf("pid ->%s ->%s\n",xpath_obj->name,NULL);
	if(NULL != xpath_obj) {
		nodeset = xpath_obj->nodesetval;
		int i = 0;
		for(i = 0; i < nodeset->nodeNr; i ++) {
			uri = xmlGetProp(nodeset->nodeTab[i],(const xmlChar*)"href");
			printf("link address:%s->%s->%s\n",uri,nodeset->nodeTab[i]->name,
			xmlNodeGetContent(nodeset->nodeTab[i]));
			xmlFree(uri);
		}
		xmlXPathFreeObject(xpath_obj);
	}
	xmlFreeDoc(doc);
	xmlCleanupParser();
	
	return 1;
}
Beispiel #2
0
static void
xml_output_xml(pcmk__output_t *out, const char *name, const char *buf) {
    xmlNodePtr parent = NULL;
    xmlNodePtr cdata_node = NULL;
    xml_private_t *priv = out->priv;

    CRM_ASSERT(priv != NULL);

    parent = xmlNewChild(g_queue_peek_tail(priv->parent_q), NULL,
                         (pcmkXmlStr) name, NULL);
    cdata_node = xmlNewCDataBlock(getDocPtr(parent), (pcmkXmlStr) buf, strlen(buf));
    xmlAddChild(parent, cdata_node);
}