I am trying to load an xml into an XDocument object.
public void ValidateRules(XmlReader xml)
{
xml.MoveToContent();
XDocument xDoc = new XDocument();
xDoc = XDocument.Load(xml);
}
But, I keep getting the error "The XmlReader state should be Interactive". I searched for a work around for this, and added MoveToContent() method at the top(as it was mentioned that, this will change the ReadState to Interactive), but it didn't work. ReadState is read-only and I cannot change the value.
What can be the problem over here?
P.S. The XML file which I am trying to load has a DTD reference. It is present at the same path as the XML. Do not know whether this is of any significance.