Thread: Xml

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep 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.
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,387
    Rep Power
    1871
    Nobody is going to bother reading your code until you post it with [code][/code] tags.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,854
    Rep Power
    481
    Code tags are necessary but not sufficient!

    What might this fragment mean?

    { = node -> next){
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by b49P23TIvg
    Code tags are necessary but not sufficient!

    What might this fragment mean?

    { = node -> next){


    thats a mistak

IMN logo majestic logo threadwatch logo seochat tools logo