updating XML stream with updated xml node

abdelaziz

New Member
I am validating an XML using XMLDocument.Validate method. I am using a File Stream instead of a physical real .xml file. First I am validating XML and then updating one specific tag where I write the error. My problem is that I want to update the node and then update back the original file stream also. Public Sub ValidateXML(ByVal xmlFilePath As String, ByVal xsdFilePath As String) As Boolean xmlStream = System.IO.File.OpenRead(xmlFilePath)\[code\] xDoc.Load(xmlStream) xDoc.Schemas.Add(Nothing, xsdFilePath) Dim eventHandler As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEventHandler) xDoc.Validate(eventHandler) End FunctionPrivate Sub ValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs) 'Get XML Parent from Exception Source Object Dim xs As XmlSchemaValidationException = TryCast(e.Exception, XmlSchemaValidationException) Dim XNode As XmlNode = DirectCast(DirectCast(xs.SourceObject, System.Object), System.Xml.XmlElement).ParentNode If e.Severity = XmlSeverityType.Error Then XNode.LastChild.InnerText = XNode.LastChild.InnerText + " : " + e.Message\[/code\]'''''''''''Here I want to add some code which will update XNode's lastchild value into main File stream End If\[code\] End Sub\[/code\]
 
Back
Top