Vijay
Vijay

Reputation: 111

Map parsed xml data into structure

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

Upvotes: 1

Views: 938

Answers (1)

Daniel Trebbien
Daniel Trebbien

Reputation: 39208

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".

Upvotes: 2

Related Questions