Get type from xsd at runtime

nantes

New Member
My questions is semi-related to: Is it possible to get the type of an XML node as it was defined in XSD?...but this question was not answered and it targets python, whereas I am interested in a C#.Net solution. My question is: how can you get a type, defined in an XSD, expressed as a type in .Net?Background:If it helps, my goal is to use xpath to locate a section within an XML document, find that section's corresponding type in the supporting XSD, and finally use the type to then de-serialize that section into a .Net object.Generally, I can de-serialize the xml if I know the type at compile-time, but at run-time, the type must be inferred using an xpath query. I think this could be achieved using reflection, but I am wondering also if there isn't something already present in the .Net Framework I could leverage.Stated another way, I'd like to do the opposite of this:\[code\]private void ExtractXsdFromType(Type type, FileInfo xsd){ XmlReflectionImporter importer = new XmlReflectionImporter(); XmlTypeMapping mapping = importer.ImportTypeMapping(type);}\[/code\]... where rather than passing in a type to get the mapping, I'd be passing in a string to get the type. I hope that is clear enough, but if not please request clarification and I will provide more details.Thanks for your experience!
 
Back
Top