Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8660567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:17:03+00:00 2026-06-12T16:17:03+00:00

I am trying to write a xml parser in C using the libxml2 on

  • 0

I am trying to write a xml parser in C using the libxml2 on cygwin on my Win 7 machine.
When i am trying to compile the code it is giving me compile time errors. Can someone help me out on this.

ad@ad-PC /cygdrive/c/Users/ad/Desktop
$ gcc xmlparser.c -I /cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/ -L /cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/lib/libxml2.lib -o pxml
In file included from /cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/parser.h:807,
             from xmlparser.c:8:
/cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/encoding.h:28:19: iconv.h: No such file or directory
In file included from /cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/parser.h:807,
             from xmlparser.c:8:
/cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/encoding.h:146: error: parse error before "iconv_t"
/cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/encoding.h:146: warning: no semicolon at end of struct or union
/cygdrive/c/Users/ad/Desktop/libxml2-2.7.8.win32/include/libxml/encoding.h:147: warning: data definition has no type or storage class
xmlparser.c: In function `main':
xmlparser.c:21: error: `filename' undeclared (first use in this function)
xmlparser.c:21: error: (Each undeclared identifier is reported only once  
xmlparser.c:21: error: for each function it appears in.)
xmlparser.c:29: error: parse error before ')' token
xmlparser.c: At top level:
xmlparser.c:34: error: parse error before string constant
xmlparser.c:34: error: conflicting types for 'printf'
xmlparser.c:34: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
xmlparser.c:34: error: conflicting types for 'printf'
xmlparser.c:34: note: a parameter list with an ellipsis can't match an empty parameter name list declaration
xmlparser.c:34: warning: data definition has no type or storage class

The code ::

# include <stdio.h>
# include <stdlib.h>
# include <libxml/parser.h>

int main(int argc, char **argv)
{
    xmlDoc *document;
    xmlNode *root , *node , *first_child;

    if(argc < 2) 
    {
        printf("\n Error No filename specified \n");
        return 1;
    }

    filename = argv[1];

    document = xmlReadFile(filename,NULL,0);
    root = xmlDocGetRootElement(document);

    printf("\n Root is ::%s:: <%i> \n",root->name,root->type);
    first_child = root->children;

    for(node = first_child;node,node = node->next)
    {
        printf("\n Child is ::%s:: <%i> \n",node -> name, node->type);
    }

    printf("\n END \n");
    return 0;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:17:04+00:00Added an answer on June 12, 2026 at 4:17 pm

    The error message says it unambiguously that filename is not declared and yet you’re trying to use it here:

    filename = argv[1];
    

    There’s also a wrong punctuator here:

    for(node = first_child;node,node = node->next)
    

    It has to be ; instead of ,.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a generic XML to Core Data parser using libxml2. Since
I am trying to write a piece of code that can parse any xml
I am trying to write some XML schema code to specify that a particular
I'm trying to write an xml file with utf-8 encoded data using ElementTree like
I am trying to write XML data using Stax where the content itself is
I'm trying to parse a simple xml document using a DOM parser in JS,
I've been trying to write a PHP script to parse an XML document using
I'm trying to write a unit test that checks some xml parsing code. The
I am trying to write a xml parser for my game, since the size
I'm trying to write an XML document using an XmlWriter and an XmlDocument .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.