D
DMan
Need some help on how to make the following faster....
Public XmlDocument ProcessXML( XmlDocument xmlData )
{
XmlNode originalXML = xmlData.Clone();
try
{
// Process XML data here...
}
catch
{
// if ANYTHING goes wrong with XML processing
// revert back to the original.
xmlData.LoadXml(originalXML.OuterXml);
return xmlData;
}
return xmlData;
}
There it is. Without cloning and reloading in the catch block, if something
goes wrong, I get SOME xml processing, which I absolutely cannot have. For
example, if some data in the XML is invalid, I throw an exception, but I
still get back all the XML processed before that error ocurred. I need to
either have the entire XML document processed error free, or revert back to
the original (as is being done in the code) if there is any error anywhere.
Can anyone think of a better approach? A faster approach?
Thank you.
Public XmlDocument ProcessXML( XmlDocument xmlData )
{
XmlNode originalXML = xmlData.Clone();
try
{
// Process XML data here...
}
catch
{
// if ANYTHING goes wrong with XML processing
// revert back to the original.
xmlData.LoadXml(originalXML.OuterXml);
return xmlData;
}
return xmlData;
}
There it is. Without cloning and reloading in the catch block, if something
goes wrong, I get SOME xml processing, which I absolutely cannot have. For
example, if some data in the XML is invalid, I throw an exception, but I
still get back all the XML processed before that error ocurred. I need to
either have the entire XML document processed error free, or revert back to
the original (as is being done in the code) if there is any error anywhere.
Can anyone think of a better approach? A faster approach?
Thank you.