
December 20th, 2012, 12:52 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 5 m 29 sec
Reputation Power: 0
|
|
|
Xml
code :
#include<stdio.h>
#include<libxml/parser.h>
#include<libxml/tree.h>
#ifdef LIBXML_TREE_ENABLED
int main(int argc, char * argv[])
{
xmlDocPtr doc;
doc = xmlReadFile((const char *)argv[1],NULL,0);
if (doc == NULL) {
printf("Failed to parse %s\n", (const char *)argv[1]);
return 1;
}
printf("XML Read Successful\n");
xmlNode * root, *cur ,* node ,*child;
root = xmlDocGetRootElement(doc);
fprintf(stdout,"%s\n", root -> name);
child = root -> xmlChildrenNode;
fprintf(stdout,"%s\n", child -> name);
for ( cur = node ;cur ; cur= node ->next){ = node -> next){
if (node -> type == XML_ELEMENT_NODE){
printf("cur : %s\n", cur->name)
return 0 ;
#else
int main(void) {
fprintf(stderr, "Tree support not compiled in\n");
exit(1);
}
#endif
ques: my these code are just returning the root element but not all the elements and children.
|