# How to color numbers in certain parts of a lstlisting

So, I'm a student and my teacher posted this kind of "how to make XML look cool in LaTeX". We were using it in class but I noticed some errors.

For example, when printing numbers inside the labels (as in <number> this is 25 </number>) the program won't print the number 25 the same color as the rest of the words.

A picture is worth a thousand words:

I'd like them printed in the same way that the rest of the text. I tried telling LaTeX to print all the numbers red, but that works too for the XML declaration. Which is not nice.

There's any way to do what I'm asking for?

Thanks for the help, I'm a total noob :D

Sorry for the bad english <3

The actual code:

\documentclass[11.5pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
\usepackage{newtxtext}

\lstdefinelanguage{XML}{
basicstyle=\ttfamily\footnotesize,
morestring=[b]",
moredelim=[s][\bfseries\color{Maroon}]{<}{\ },
moredelim=[s][\bfseries\color{Maroon}]{</}{>},
moredelim=[l][\bfseries\color{Maroon}]{/>},
moredelim=[l][\bfseries\color{Maroon}]{>},
morecomment=[s]{<?}{?>},
numberstyle=\color{red}
morecomment=[s]{<!--}{-->},
stringstyle=\color{blue},
identifierstyle=\color{red},
extendedchars=true,
literate=
{á}{{\textcolor{red}{\'a}}}{1}
{é}{{\textcolor{red}{\'e}}}{1}
{í}{{\textcolor{red}{\'i}}}{1}
{ó}{{\textcolor{red}{\'o}}}{1}
{ú}{{\textcolor{red}{\'u}}}{1}
{ñ}{{\textcolor{red}{\"n}}}{1},
}

\begin{document}
\lstset{language=XML}
\begin{lstlisting}
<number> This is 25</number>
\end{lstlisting}
\end{document}

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Reinstate Monica - M. Schröder Nov 30 '15 at 21:29