Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to serialize xml schema file(.xsd). While serializing objects I got an error "tt:" prefix is not defined. Can any one solve this issue? Find the xml schema file below.

XML
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tds="http://www.my.org/ver10/device/wsdl" xmlns:trt="http://www.my.org/ver10/media/wsdl" xmlns:tt="http://www.my.org/ver10/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tev="http://www.my.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:tptz="http://www.my.org/ver10/ptz/wsdl" xmlns:tns1="http://www.my.org/ver10/topics" xmlns:tnsaxis="http://www.camera.com/2009/event/topics">
- <soap:Body>
- <tds:GetCapabilitiesResponse>
- <tds:Capabilities xsi:type="tt:Capabilities">
- <tt:Media xsi:type="tt:MediaCapabilities">
<tt:XAddr>http://192.168.3.101/onvif</tt:XAddr>
- <tt:StreamingCapabilities xsi:type="tt:RealTimeStreamingCapabilities">
<tt:RTPMulticast>true</tt:RTPMulticast>
<tt:RTP_TCP>true</tt:RTP_TCP>
<tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP>
</tt:StreamingCapabilities>
- <tt:Extension xsi:type="tt:MediaCapabilitiesExtension">
- <tt:ProfileCapabilites xsi:type="tt:ProfileCapabilities">
<tt:MaximumNumberOfProfiles>5</tt:MaximumNumberOfProfiles>
</tt:ProfileCapabilites>
</tt:Extension>
</tt:Media>
</tds:Capabilities>
</tds:GetCapabilitiesResponse>
</soap:Body>
</soap:Envelope>



I am using this method to deserialize the shcema file.

C#
XmlSerializer xmlSerializer;
MemoryStream memStream = null;
try
{
   xmlSerializer = new XmlSerializer(type);
   byte[] bytes = new byte[xmlString.Length];
   Encoding.ASCII.GetBytes(xmlString, 0, xmlString.Length, bytes, 0);
   memStream = new MemoryStream(bytes);
   object objectFromXml = xmlSerializer.Deserialize(memStream);
   return objectFromXml;
}
catch (Exception Ex)
{
   throw Ex;
}
finally
{
   if (memStream != null) memStream.Close();
}


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 28-Mar-11 4:05am
v3
Comments
HimanshuJoshi 28-Mar-11 10:05am    
Corrected code block.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900