2

I am working on some test automation where we are using xml documents for some test input. Now I am loading the xml documents to dataset and from dataset I am accessing the data.

For easy accessing, I have defined some classes with the similar xml schema.

Once I am done with the loading of xml into dataset, creating instances of my defined classes with the data from dataset. And accessing these objects from tests.

But here the maitainance of class structure and xml in sync is too difficult. If there is any change in the xml such as adding a new node, I have to change my class structure and the initializing the class to accomdate the new property.

I am looking for some methodology where I can avoid the keeping insync of xml and class structure. I am basically looking for some Automapper inbetween the xml and my C# classes.

-Naresh

Naresh
  • 2,667
  • 13
  • 44
  • 69
  • 1
    Can you add some concrete examples? I don't see how an automapper would understand how to resolve differences between xml and class structure. Why don't you keep the data weakly typed? And why are you loading into a dataset, and then creating class instances? Couldn't you simply use `XmlSerializer` or data contracts? – vgru Jun 18 '12 at 12:04
  • Maybe this can help you out: http://stackoverflow.com/questions/87621/how-do-i-map-xml-to-c-sharp-objects or this one: http://stackoverflow.com/questions/386155/comparison-of-xsd-codegenerators-c – Rob Angelier Jun 18 '12 at 12:04
  • I am not updating xml back. I just need to read the xml. And after reading the xml, I have to filter out the records based on some input. I felt, for filtering records dataset would be a better option. Please correct me if I am wrong. – Naresh Jun 26 '12 at 08:35

0 Answers0