[tex]y'+xy=xy^2\implies y^{-2}y'+xy^{-1}=x[/tex]
Let [tex]z=y^{-1}[/tex], so that [tex]z'=-y^{-2}y'[/tex]. Then the ODE becomes linear in [tex]z[/tex] with
[tex]-z'+xz=x\implies z'-xz=-x[/tex]
Find an integrating factor:
[tex]\mu(x)=\exp\left(\displaystyle\int-x\,\mathrm dx\right)=e^{-x^2/2}[/tex]
Multiply both sides of the ODE by [tex]\mu[/tex]:
[tex]e^{-x^2/2}z'-xe^{-x^2/2}z=-xe^{-x^2/2}[/tex]
The left side can be consolidated as a derivative:
[tex]\left(e^{-x^2/2}z\right)'=-xe^{-x^2/2}[/tex]
Integrate both sides with respect to [tex]x[/tex] to get
[tex]e^{-x^2/2}z=e^{x^2/2}+C[/tex]
where the right side can be computed with a simple substitution. Then
[tex]z=1+Ce^{x^2/2}[/tex]
Back-substitute to solve for [tex]y[/tex].
[tex]y^{-1}=1+Ce^{x^2/2}\implies y=\dfrac1{1+Ce^{x^2/2}}[/tex]