Hello @warappa ,
In your code I can see you use:
[XmlRoot("BMECAT", Namespace = "http://www.bmecat.org/bmecat/2005")]
public class BMEcatDocument
This does not work with my BMECAT, because it uses:
<BMECAT xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2005" xmlns="http://www.bmecat.org/bmecat/2005fd">
You see, it has the ending 2005fd in the namespace.
When I change it in the XML to 2005 at the end it is working.
Can I get this working somehow by using any parameter or option?
My code looks like this:
public static BMEcatDocument GetBMEcatDocument(
this Stream stream,
out string errorMessage,
BMEcatXmlSerializerOptions options = null)
{
// init return values
BMEcatDocument theDoc = null;
errorMessage = null;
// get serializer factory
BMEcatXmlSerializerFactory fac = new BMEcatXmlSerializerFactory(
options ?? new BMEcatXmlSerializerOptions
{
// add default options if needed
});
// deserialize and validate the document
try
{
XmlSerializer serializer = fac.Create<BMEcatDocument>();
theDoc = serializer.Deserialize<BMEcatDocument>(stream);
theDoc.EnsureValid(serializer);
}
catch (Exception exc)
{
errorMessage = exc.Message;
}
return theDoc;
}
}
Hello @warappa ,
In your code I can see you use:
This does not work with my BMECAT, because it uses:
<BMECAT xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2005" xmlns="http://www.bmecat.org/bmecat/2005fd">You see, it has the ending 2005fd in the namespace.
When I change it in the XML to 2005 at the end it is working.
Can I get this working somehow by using any parameter or option?
My code looks like this: