# Tuesday, August 05, 2003

So far I’ve done some experiments with a couple of the options I mentioned in my last post.   I tried styling the incoming XML document into something I could read into a dataset, and then used SqlDataAdapter.Update to persist the changes.  This works pretty well, but the biggest issue ends up being foreign key constraints.  I think you’d either have to do some pretty funky stuff in the stylesheet, or clean up the foreign keys once they were in the dataset, although that only works if your dataset doesn’t have constraints to begin with. 

Then I tried OPENXML, and I’ve got to say that so far that’s the way I’m leaning.  It turned out to make things much easier if I style the incoming XML into a simpler format (without all the namespaces) then pass that to OPENXML.  The OPENXML code turned out to be way less hairy than I had thought it might be, and I can handle the transaction in the stored proc rather than using DTC transactions.  All in all, not a bad thing.  It’s almost enough to make me not care if things change in Yukon in ways that would make this not work, or be obsolete.  It’s pretty slick in the near term.  I haven’t tried any performance testing, but it seems to me that the OPENXML solution is faster. 

I could try the other option of parsing the XML in C# and then making transacted ADO.NET calls to persist the data, but I don’t really want to go there.  It’s the business-layer XML parsing I’m trying to get rid of, and it’s a lot more code.