I'm creating an application that allows a user to validate an XML document and update the document where the errors occur. First I load the XML document into a TreeView. Then I validate then document against a schema, which gives me a bunch of XmlSchemaException objects.
The problem is this - how do I find the error in the TreeView based on the schema exception? The exception tells me what line number the error occurs, but how do I translate that into an element in the XmlDocument, or even better - a node of the TreeView?
I found this article on MSDN that shows how to extend the XMLDocument object to capture line numbers by extending the XMLElement object. But when I populate the TreeView, I do so by doing a:
[tt][blue]For Each[/blue] node [blue]As[/blue] XmlNode [blue]In[/blue] document.ChildNodes[/tt]
I can't cast an XmlNode into my custom XmlElement, and there isn't a ChildElements collection as far as I can tell, so I'm kinda stuck.
Any ideas?
Thanks,
Adam
The problem is this - how do I find the error in the TreeView based on the schema exception? The exception tells me what line number the error occurs, but how do I translate that into an element in the XmlDocument, or even better - a node of the TreeView?
I found this article on MSDN that shows how to extend the XMLDocument object to capture line numbers by extending the XMLElement object. But when I populate the TreeView, I do so by doing a:
[tt][blue]For Each[/blue] node [blue]As[/blue] XmlNode [blue]In[/blue] document.ChildNodes[/tt]
I can't cast an XmlNode into my custom XmlElement, and there isn't a ChildElements collection as far as I can tell, so I'm kinda stuck.
Any ideas?
Thanks,
Adam