EDN Admin
Well-known member
Hi all,
I have a simlpe xsd file. using xsd utility I can create classes (in my example the root XmlElement is named "RESULT") that represent my xsd and work with xml file that correspond this xsd.<br/>
F. e:<br/>
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small System.IO.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small StreamReader<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
str = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small new<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
System.IO.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small StreamReader<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "XMLFile1.xml"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small );<br/>
System.Xml.Serialization.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XmlSerializer<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
xSerializer = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small new<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
System.Xml.Serialization.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XmlSerializer<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small typeof<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ));<br/>
<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
res = (<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small )xSerializer.Deserialize(str);<br/>
... process xml file ....
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Suppose I know the possible types, that could be in xsd file, is it possible to create this classes dynamically and not using xsd utility?
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Thanks a lot for help,
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Alex
<br/>
View the full article
I have a simlpe xsd file. using xsd utility I can create classes (in my example the root XmlElement is named "RESULT") that represent my xsd and work with xml file that correspond this xsd.<br/>
F. e:<br/>
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small System.IO.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small StreamReader<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
str = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small new<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
System.IO.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small StreamReader<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "XMLFile1.xml"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small );<br/>
System.Xml.Serialization.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XmlSerializer<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
xSerializer = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small new<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
System.Xml.Serialization.<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XmlSerializer<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small typeof<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small (<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ));<br/>
<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
res = (<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small RESULT<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small )xSerializer.Deserialize(str);<br/>
... process xml file ....
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Suppose I know the possible types, that could be in xsd file, is it possible to create this classes dynamically and not using xsd utility?
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Thanks a lot for help,
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small Alex
<br/>
View the full article