# Multiple labels on edge in TikZ

The following MWE produces an edge between two nodes with label x above and label y below the edge:

I draw the edge twice to achieve this. Is there a more elegant way?

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {};
\node (b) at (2,0) {};
\draw (a) to node[above] {x} (b);
\draw[fill=none] (a) to node[below] {y} (b);
\end{tikzpicture}
\end{document}


You can add two nodes to the same path.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\node (a) at (0,0) {};
\node (b) at (2,0) {};
\draw (a) to node[above] {x} node[below] {y} (b);
\end{tikzpicture}
\end{document}