2011-02-04 3 views

답변

0

XSD에서 생성 된 MyClass 클래스가 있고이 파일을 MySample.xml에 해당 클래스에 맞는 XML 데이터가 있다고 가정하면 다음과 같은 작업을 수행 할 수 있습니다 (죄송합니다. 저는 VB에 익숙하지 않습니다. C#입니다.) :

// create the XML serializer class, based on your MyClass definition 
XmlSerializer ser = new XmlSerializer(typeof(MyClass)); 

// create filestream to open & read the existing XML file 
FileStream fstm = new FileStream(@"C:\mysample.xml", FileMode.Open, FileAccess.Read); 

// call deserialize 
var result = ser.Deserialize(fstm); 

// if result is not null, and of the right type - use it! 
MyClass deserializedClass = (result as MyClass); 
if(deserializedClass != null) 
{ 
    // do whatever you want with your new class instance! 
} 

도움이 되나요 ??

관련 문제