This question might sound similar to other question in Stack Overflow, but is different.
I am trying to load an XML file using new XmlDocument() & LoadXml(). While doing so there are some xml tags that are incomplete or incorrect and due to it is throwing exception. I want to make a list of them. Now I want this line number from exception object:
I want to extract line number pointed with RED arrow (which I thought would be ex.LineNumber, but it is not). I can extract from ex.Message (highlighted with YELLOW), but if it is available (like the place marked with RED arrow) then I would like to figure out how to get that value. Or is it not possible?
More clarification: Also if you look at StackTrace then you might find that that is another line number (Line 47) mentioned in the end but that's not what I am looking for (shown below).
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at <ProjectName>.Program.EvaluateEpisodeList(String strSeriesHomePageCode) in C:\<Path>\<ProjectName>\Program.cs:line 47
Hope this clarifies my question.
Most of the similar question on internet is for extracting line number from StackTrace, I didn't find anything that would solve my problem.
Thanks in advance.
