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.
XML data is null attempt read via reader. reader's ReadState situation will be Initial or EndOfFile (https://msdn.microsoft.com/en-us/library/fxtcxd31.aspx)
public void ValidateRules(XmlReader reader)
{
XDocument xDoc = XDocument.Load(reader);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With