Step 1: Look for a clever pattern.
The bottom has the angle $x e^x$ inside a cosine squared. If the top is the derivative of that angle, a simple substitution will work. So we first check the derivative of $x e^x$.
Step 2: Differentiate the inside angle.
Using the product rule on $x e^x$, we get $1\cdot e^x + x\cdot e^x = e^x(1 + x)$. This matches the numerator exactly.
Step 3: Make the substitution.
Let $u = x e^x$. Then from the step above, $du = e^x(1 + x)\,dx$. So the whole numerator is just $du$.
Step 4: Rewrite the integral.
Replace the top with $du$ and the angle with $u$.
\[ \int \frac{du}{\cos^2 u} = \int \sec^2 u\,du \]
Step 5: Use the standard integral.
We know the integral of $\sec^2 u$ is $\tan u$.
\[ \int \sec^2 u\,du = \tan u + C \]
Step 6: Replace $u$ back.
Put $u = x e^x$ back in.
\[ \tan(x e^x) + C \]
\[ \boxed{\tan(x e^x) + C} \]