DeSerializing XML data to an object RRS feed

  • Question

  • Hello All,

    I want to serialize below XML into an object.

    	<node action="create" type="project">
    		<description clear="true"></description>
    		<goals clear="true"></goals>
    		<initiatives clear="true"></initiatives>
    		<objectives clear="true"></objectives>
    			<coordinator type="user"><![CDATA[ABC]]></coordinator>
    			<guest type="group"><![CDATA[KBC-All]]></guest>
    			<member type="group"><![CDATA[KBN-PPT]]></member>
    <node action="create" type="document">
    		<acl permissions="454545454" role="Members"></acl>
    		<acl baseowner="KJNH" permissions="111111111"></acl>		
    		<category name="My Categories:CCD">
    			<attribute name="Status"><![CDATA[POSTPONE]]></attribute>
    			<attribute name="Effective Date"><![CDATA[20130308]]></attribute>
    			<attribute clear="true" name="PPB"></attribute>			
    			<setattribute name="Function">
    				<attribute name="Function"><![CDATA[gdfr]]></attribute>
    				<attribute clear="true" name="Sub-Function"></attribute>
    		<category name="My Categories:Information">
    			<attribute name="Author"><![CDATA[KIO]]></attribute>

    Please guide me how do I design classes with XML attribute & XML elements so that they get deserialise to an object once I load the XML. Can you please share sample code for this

    Any help is greatly appreciated.

    Thanks, Alex


    • Edited by Alex Cardo Monday, September 7, 2015 11:45 AM
    Monday, September 7, 2015 11:43 AM


  • I want to serialize below XML into an object.

    You make concrete classes/objects.

    You can use Linq-2-XML.

    You can use a Linq projection to project the results into a concrete class/object.

    Or you can use Xpath and populate a concrete class/object

    Monday, September 7, 2015 5:46 PM