In the repro, two XML variables are loaded through a FOR XML PATH TYPE query. The documents are nested: they described Orders and OrderDetails. The documents are similar, the one difference is that one is attribute-centric and the other is element-centric. The documents include 830 orders and 2155 details elements.
These variables is then passed to a stored procedure, which first selects the size the of the XML documetns and then shreds the documents and inserts orders and details into tables. This done for both parameters. The execution time for the query that retrieves the details is unacceptable > 10 seconds.
Next the variables are assigned to nvarchar(MAX) variables, and the stored procedure is called anew. The performance of all queries is now perfectly acceptable. The size of the documents is smaller this time as well.
The conclusion is that the XML values created by the FOR XML TYPE queries include some extra fluff that makes the XML readers go crazy.
This is regression from SQL 2005; This behaviour does not appear in SQL 2005 SP3. (But the document has difference sizes on SQL 2005 as well.)