2
It might be simpler and better performing to use Node Order Comparison Operators in order to count the preceding //comment nodes in the XML tree.
I didn't test on huge XML documents, but it's definitely less I/O intensive, and was less CPU intensive on my contrived tests.
declare @x xml = N'<po...