how to validate xml based on the DTD by using libxml2 xml parse in c

poke386

New Member
My assignment is to differentiate xml content in to groups ,for example i have two xml files\[code\]<?xml version="1.0"?><marks><firstname>john</firstname><lastname>peter</lastname><subject name="english" marks="30">pass</heading></marks><?xml version="1.0"?><marks><firstname>james</firstname><lastname>cameron</lastname><subject name="english" marks="30" degree="masters">pass</heading></marks>\[/code\]So i need to parse above example xml files and need to divide them in to groups, and calculate the number of master students, phd students, bachelor studentsEach group will have and additional properties in element section, like for masters students subject element" will have an property degree for phd students they will an property of specializationI can get the properties of the xml files and code it in the c function saying if we have property name degree consider them as masters students but is there any other way round likeconstruct the DTD based on the xml requests and just using libxml2 to validate the DTD and differentiate requests (which i have to figure it out by using libxml2 library, don't know yet)As the number of different type of xml request increases, i cannot hard code them writing multiple if loops.it would be possible to just create a dtd for particular type of request and just using one line of code to validate against that request but now sure is it really possible..request you to give your thoughts.
 
Back
Top