Massive hot stars are strong sources of X-ray emission originating in their winds. Although hydrodynamical wind simulations that are able to predict this X-ray emission are available, the inclusion of X-rays in stationary wind models is usually based on crude approximations. To improve this, we use results from time-dependent hydrodynamical simulations of the line-driven wind instability to derive an analytical approximation of X-ray emission in the stellar wind. We use this approximation in our non-LTE wind models and find that an improved inclusion of X-rays leads to a better agreement between model ionization fractions and those derived from observations. Furthermore, the slope of the Lx-L relation is in better agreement with observations, albeit the X-ray luminosity is underestimated by a factor of three. We propose that a possible solution for this discrepancy is connected with the wind porosity.