[Tex/LaTex] newline symbol in beamer?


If I use \\ or $\newline$ in beamer inside a tikzpicture, I get the following error:

Something's wrong–perhaps a missing \item. \end{frame}

What is correct use of it?

My tikz code is as follows:

\setbeamertemplate{footline}[page number]{}
\setbeamertemplate{navigation symbols}{}


\begin{tikzpicture}[->,shorten >=1pt,auto,node distance=7 cm,
                semithick, scale = 0.4, transform shape]

\node[initial,state] (A)                    {$s_0$};
\node[state]         (B) [above right of=A] {$s_1$};
\node[state]         (C) [below right of=A] {$s_2$};
\node[state]         (D) [below right of=B] {$s_3$};
\node[state]         (E) [above right of=D] {$s_4$};
\node[state]         (F) [below right of=D] {$s_5$};

  \path (A) 
    edge [left] node [blue, pos=0.5, sloped, above] {$0 \rightarrow [x = x.0.0]$} (B)
    edge [left] node [cyan, pos=0.8]{$1 \rightarrow [x = x.0.1]$} (C)(B) 
    edge [loop above] node [align=center] {$0 \rightarrow$ \\ $[x = x.0]$ }   (B)
    edge [bend right,left] node  {$1 \rightarrow [x = x.1]$ }   (C)
    edge [] node [red, pos=0.2] {$\$  \rightarrow  [x = x.0.\$]$ } (D);   



Best Answer

Change the line

edge [loop above] node [align=center] {$0 \rightarrow$ $\\$ $[x = x.0]$ }   (B)


edge [loop above] node [align=center] {$0 \rightarrow$ \\ $[x = x.0]$ }   (B)

\\ should not be in math mode, i.e., inside a pair of $\\$.