That looks like a buggy regex, after the closing </State>
you are using \\n\\s*\\n\\s*</Table>
which seems to ignore the the <id>...</id>
elements. Have you looked at using some XML parsing library in a UDF? It might be easier than trying to build a bunch of regexes by hand.
EDIT: One other suggestion. Are you sure that the line separators in your file are just \n
, you may have \r\n
as the separator, in which case [\r\n]+
should help see this post for more details.