Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML file to Class

Status
Not open for further replies.

Laeg

Programmer
Nov 29, 2004
95
IE
Is there anyway I can take an XML file and generate a class from it? There are no schemas available for these files, just plain XML.
 
yes, write the mapping object yourself. the object shouoldn't know about the xml file and the xml shouldn't know about the object.
Code:
public class XmlToClassMapper
{
   public MyClass MapFrom(XmlNode node)
   {
      return new MyClass {Property = (type)xmlnode["attribute"];}
   }
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top