value
을 child atribute
으로받는 방법은 무엇입니까? 예 : xml :libxml 자녀 atribute를 얻는 방법
<root>
<child>
<info>Lala</info>
</child>
</root>
나는 어떻게 Lala
을 얻습니까? 나는 이것을 시도 (하지만 :(작동 나던) 내가하지 LaLa
얻을이 코드를 시작하면
void parsePackage (xmlDocPtr doc, xmlNodePtr cur) {
xmlChar *key;
xmlChar *uri;
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *)"child"))) {
key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
uri = xmlGetProp(cur, (const xmlChar *)"info");
printf("Info: %s\n", uri);
xmlFree(key);
}
cur = cur->next;
}
return;
}
void parseDoc() {
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlParseFile("test.xml");
if (doc == NULL) {
fprintf(stderr,"Document not parsed successfully. \n");
return;
}
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
fprintf(stderr,"empty document\n");
xmlFreeDoc(doc);
return;
}
if (xmlStrcmp(cur->name, (const xmlChar *) "root")) {
fprintf(stderr,"document of the wrong type, root node != package");
xmlFreeDoc(doc);
return;
}
parsePackage(doc, cur);
xmlFreeDoc(doc);
return;
}
), 나는 null
를 얻을.
편집자 (귀하의 게시물이 주로 코드 인 것 같습니다. 자세한 내용을 추가하십시오.)이 케이스에 대한 자세한 내용은 없습니다.
예 잘못된 인쇄물 D – ternes3