Step 1: Spot the derivative of xe^x:
Multiply the numerator and the denominator by $e^x$: $\frac{(x+1)e^x}{xe^x(1+xe^x)^2}$. The numerator $(x+1)e^x$ is exactly $\frac{d}{dx}(xe^x)$. So with $t = xe^x$ the integral is $\int\frac{dt}{t(1+t)^2}$.
Step 2: Shift to u = 1 + t:
Let $u = 1 + t$, so $t = u - 1$. The integral is $\int\frac{du}{(u-1)u^2}$. Decompose: $\frac{1}{(u-1)u^2} = \frac{1}{u-1} - \frac{1}{u} - \frac{1}{u^2}$. This can be checked at $u = 2$: the left side is $\frac{1}{4}$ and the right is $1 - \frac{1}{2} - \frac{1}{4} = \frac{1}{4}$.
Step 3: Integrate:
$\int\left(\frac{1}{u-1} - \frac{1}{u} - \frac{1}{u^2}\right)du = \ln|u-1| - \ln|u| + \frac{1}{u} + c$. Back in $t$ and then $x$, this is $\ln\frac{xe^x}{1+xe^x} + \frac{1}{1+xe^x} + c$.
Step 4: Verify by differentiation:
Differentiate $\ln\frac{t}{1+t} + \frac{1}{1+t}$ with respect to $t$: $\frac{1}{t} - \frac{1}{1+t} - \frac{1}{(1+t)^2} = \frac{1}{t(1+t)} - \frac{1}{(1+t)^2} = \frac{1}{t(1+t)^2}$. So option (B) is right. Option (A) would differentiate to $-\frac{1}{t(1+t)} - \frac{1}{(1+t)^2}$, which is negative and does not match. Option (D) gives the negative of the integrand. Option (C) gives $-\frac{1}{t(1+t)} + 1$, which does not match either.
Final Answer:
Differentiating option (B) returns the integrand, so the answer is (B).
\[ \boxed{\log\left(\frac{xe^x}{1+xe^x}\right)+\frac{1}{1+xe^x}+c} \]