V
VRSki
I am trying to deserialize a .csdl file, generated by EdmGen.exe (part of MS
Entity Framework). The file itself is an xml file, even though it has a .csdl
extension. But unfortunately, the second line contains an element that
doesn't seem to be supported by XML serializer:
------- XML start --------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="SomeProject" Alias="Self"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<Element1>data</Element1>
</Schema>
------- XML end --------------------------------------------------------
Here is the code I use to deserialize this fileL:
// read in the file into the stream
System.IO.Stream oCsdlXml = ....
// create the serializer -- Schema class contains Element1 member
XmlSerializer oSerializer = new XmlSerializer(typeof(Schema));
// this line below throws exception:
Schema oSchema = oSerializer.Deserialize(oCsdlXml) as Schema;
Exception: "There is an error in XML document (2, 2)"
Internal Exception: "<Schema
xmlns='http://schemas.microsoft.com/ado/2006/04/edm'> was not expected."
If I take out this part from the xml file -- it all works and my Element1 is
properly deserialized:
xmlns="http://schemas.microsoft.com/ado/2006/04/edm"
Is that a truly invalid XML construct? Is there any way to deserialize this
using attribute overrides?
Thank you for your help,
VR
Entity Framework). The file itself is an xml file, even though it has a .csdl
extension. But unfortunately, the second line contains an element that
doesn't seem to be supported by XML serializer:
------- XML start --------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<Schema Namespace="SomeProject" Alias="Self"
xmlns="http://schemas.microsoft.com/ado/2006/04/edm">
<Element1>data</Element1>
</Schema>
------- XML end --------------------------------------------------------
Here is the code I use to deserialize this fileL:
// read in the file into the stream
System.IO.Stream oCsdlXml = ....
// create the serializer -- Schema class contains Element1 member
XmlSerializer oSerializer = new XmlSerializer(typeof(Schema));
// this line below throws exception:
Schema oSchema = oSerializer.Deserialize(oCsdlXml) as Schema;
Exception: "There is an error in XML document (2, 2)"
Internal Exception: "<Schema
xmlns='http://schemas.microsoft.com/ado/2006/04/edm'> was not expected."
If I take out this part from the xml file -- it all works and my Element1 is
properly deserialized:
xmlns="http://schemas.microsoft.com/ado/2006/04/edm"
Is that a truly invalid XML construct? Is there any way to deserialize this
using attribute overrides?
Thank you for your help,
VR