NewDocumentEnvironment causes extra row [duplicate]

When I use NewDocumentEnvironment of xparse and place a table to be inside this environment, I get an extra row at the end. Same code does not cause extra row in standard newenvironment. Is there a solution to this problem? I have tried using \ignorespaces and made entire thing single line without spaces, still the same result. I have compiled a MWE below:

\documentclass{article}

\usepackage{xparse}

\NewDocumentEnvironment{test}{}{%
\begin{tabular}{|l|l|l|}\hline%
A & B & C \\\hline%
}{%
\end{tabular}%
}

\newenvironment{testtwo}{%
\begin{tabular}{|l|l|l|}\hline%
A & B & C \\\hline%
}{%
\end{tabular}%
}

\begin{document}
\begin{test}
This & does not & work\\\hline
\end{test}

~\\~\\

\begin{testtwo}
This & does & work\\\hline
\end{testtwo}
\end{document}


Result:

marked as duplicate by Maarten Dhondt, user13907, Romain Picot, AboAmmar, Joseph Wright♦Jan 6 '16 at 10:11

• Thank I now understand the problem better, I thought about extra space causing new row. But that does not help to solve it though, unless I would change \NewDocumentEnvironment. Is there a way around it? – Cem Kalyoncu Jan 6 '16 at 8:48