tags:

views:

28

answers:

1

I am new to the XML and parsing. Just started! Using Expat XML Parser in C on Linux i.e. libexpat.so and expat.h. I would like to know that, is it possible to parse the xml file (elements, attributes and its values or strings) and create or map it as structure i.e. to form the structure from XML data available in the XML file??? Is there any API available from Expat library to achieve this in C?

Please let me know any information or pointers, thank you

+2  A: 

There is an essay online, titled "Building A Data Structure With Expat. Part 2: Flat Documents To Data Structures", which appears to be exactly what you are looking for. I would try to adapt the pattern that David Howard presents in this essay to your problem.

Alternatively, and if C++ is an option, you can try the libraries for XML-to-C++ structures that are listed in the answer to "Mapping C structure to an XML element".

Daniel Trebbien
Thanks Daniel, I appreciate the pointers you sent me. And I think now I am getting to approach to achieve my requirement.
Vijay