tags:

views:

55

answers:

4

In my SSIS Package, I am using an XML file that was downloaded by another process.

Before I proceed to other portions of work in the package, I want to ascertain that the file downloaded completely.

I have the XSD file handy as well.

How do I verify in SSIS that the XML file downloaded properly?

+1  A: 

If the file downloaded correctly and completely it should obviously be valid. So check against the Schema.

Teja Kantamneni
+2  A: 

To be valid XML, the document must contain a single element node (which may itself contain a number of other nodes). In short, you need to get the closing tag for the opening tag to know you have the whole document. Validating this document against a schema is secondary to this, but may help (or be done at the same time).

Bruno
+2  A: 

I agree to Bruno and Teja: The file should be valid and you should see the closing tag. However, I think you might be adressing the problem from the wrong perspective. Could you consider

  • Checking the return value of the download process?
  • Downloading to a temporary file (e.g. Firefox uses file.txt.part) and move it to the correct path atomically after the download has finished?

It seems to me that you're requirement is that the download process be reliable, so you should try to guarantee this rather than to handle the unreliability in your program.

Jonas Wagner
@Jonas Wagner, In the question it says that the file is downloaded by other process. This process will have no idea of the return value.
Teja Kantamneni
+1  A: 
try
XmlDoc = new XMLDocument()
Using XmlStream As New StreamReader(filename)

       content = XmlStream.ReadToEnd()
       XmlDoc.LoadXml(content)

       // write your code here. If it comes here it means file download is complete.

End Using

catch xex as XMLException
// error handling routine

end try
A_Var