How to solve the differential equation $y'=\frac{y-xy^2}{x+x^2y}$ $$y'=\frac{y-xy^2}{x+x^2y}$$
This is the equation I want to solve.
My idea is to substitute $xy$ with $u,$ $u=xy$ and $\frac{du}{dx}=xy'+y.$
So, the equation becomes
$y'=\frac{y(1-u)}{x(1+u)}.$
What I am struggling with is how to deal with the $x$ and $y$ that are left in the equation.

Solve
\begin{gather*}
\boxed{y^{\prime}-\frac{y-x y^{2}}{x +x^{2} y}=0}
\end{gather*}
Using $u=yx$ the above becomes
\begin{align*}
u' &= \frac{2 u}{x \left(u +1\right)}
\end{align*}
This is separable. Integrating gives
\begin{align*}
\left(\frac{u +1}{u}\right)\mathop{\mathrm{d}u}&= \left(\frac{2}{x}\right)\mathop{\mathrm{d}x}\\   
\int \left(\frac{u +1}{u}\right)\mathop{\mathrm{d}u}&= \int \left(\frac{2}{x}\right)\mathop{\mathrm{d}x}
\end{align*}
Which gives
\begin{align*}
u +\ln \left(u \right) = 2 \ln \left(x \right)+c_{1}
\end{align*}
Replacing $u \left(x \right)$ in the above solution by $yx$ gives
\begin{align*}
x y+\ln \left(x y\right)-2 \ln \left(x \right)-c_{1} = 0
\end{align*}
This is implicit solution. If you want explicit, you'll have to deal with LambertW special function.
