I’ve created a schema definition that starts like the following …
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:my.namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:it="urn:mynamespace">
<xs:annotation>
<xs:appinfo>My annotation</xs:appinfo>
</xs:annotation>
Then I load the schema and I compile it with:
System.Xml.Schema.XmlSchemaSet set = new System.Xml.Schema.XmlSchemaSet();
set.Add(schema);
set.Compile();
but I can’t manage to get back my annotation, what am I missing ?
Addition:
Thankd to Morawski reply, the code I ended up is:
string appInfoValue = string.Empty;
var annotation = schema.Items.OfType<XmlSchemaAnnotation>().FirstOrDefault();
if (null != annotation)
{
var appInfo = annotation.Items.OfType<XmlSchemaAppInfo>().FirstOrDefault();
if (null != appInfo)
{
appInfoValue = appInfo.Markup[0].InnerText;
}
}
Well, I really suppossed that should be simpler 🙂
Secrets of the System.Xml.Schema Namespace (on MSDN)
(Note: dated 2004; not tested, not confirmed)