I have this xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<xsd:element name="F">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="A" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
This xml is valid, but it is wrong
<F><F>
<A/>
</F></F>
I have to valid only this xml
<F>
<A/>
</F>
How to do it in xsd?
C# code
XmlDocument xml = new XmlDocument();
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(xml)))
{
xml.Load(ms);
}
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add("", xsdpath);
XDocument _xml = XDocument.Parse(xml.OuterXml);
_xml.Validate(schemas, (o, e) =>{});