| Suraaj Vyas 2005-03-15, 6:48 pm |
| Thank you Martin for the help, it worked. There is one more question if you
can answer it will save me a lot of time. I am sending you the whole XML file
just see that there is a weak typing done by the XML Serializer. I am sending
you the code also. I am making a web service which returns the serialized
object model (i dont have acces to the code of the object model but i am
gettting it through web service). But when I serialize it, it was giving me
that one of the element was not expected so added the type to the serializer
constructor, which resolved that problem but now is giving me weak typing for
the same element which i added through the constructor. It will be more clear
to you when u see the code. and Xml. Please help me as it is really causing
me lot of problems. I am new guy to these things and I am lost.
code for serialzing the object model
public static string SerializeInventory(object obj)
{
XmlSerializer ser = new XmlSerializer(obj.GetType(), new Type[]{ typeof
(EventTalentInfo) });
StringBuilder sb = new StringBuilder();
StringWriter writer = new StringWriter(sb);
ser.Serialize(writer, obj);
return sb.ToString();
}
Xml file
<Inventory xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns:invent="http://tempuri.org/">15</id>
<eventInfo xmlns:invent="http://tempuri.org/">
<id>0</id>
<talent>
<anyType xsi:type="EventTalentInfo">
<id>0</id>
</anyType>
<anyType xsi:type="EventTalentInfo">
<id>0</id>
</anyType>
</talent>
</eventInfo>
</Inventory>
You can see that Inventory/eventInfo/talent has anyType tag which is a weak
typing
please let me know what i can do for that.
Thanx a million
Suraaj
|