tags:

views:

117

answers:

0

Hi,

I have an application that makes hundreds of calls to a third party web service. Each time a call is made the response is parsed into XElement and a series of operations are performed on it. The processed XElement is then added to an XDocument that is later saved to disk.

Occasionally a response will include some bad data. In this situation the XElement doesn’t seem to complain when it parses the response but the bad data causes the XDocument.Save() call to fail when the output document is written to disk.

I in a perfect work I would validate the XElement but I don’t want the overhead of using xsd. Any ideas?

Thanks, Chris

        XElement final = new XElement("Response");
        while (this.output.Count > 0)
        {
            try
            {
                Request request = (Request)this.output.Dequeue();
                final.Add(request.ToXml());
            }
            catch (Exception ex)
            {
                // error logging
            }

        }
        final.Save("output.xml");