Empirical ionization fractions of C IV, N v, Si IV, and empirical ionization plus excitation fractions of C III* and N IV* in the winds of 34 O stars and one B star have been derived, We combine the mass-loss rates derived from radio measurements and H alpha with the line fitting of ultraviolet resonance lines and subordinate Lines using the Sobolev plus exact integration (SEI) method. The dependence of the empirical ionization fractions, [q], on the stellar effective temperature and on the mean wind density is discussed. This sets constraints for the models of ionization in the winds of hot stars, The ionization and excitation fractions can be expressed in terms of an empirical radiation temperature. This radiation temperature scales with T-eff,, and we derive empirical relations for T-rad as a function of T-eff. The radiation temperatures are on the order of 0.5-0.9 T-eff, with significant differences between the ions. The derived relations between the ionization fractions and the stellar parameters have an uncertainty of 0.2 dex for Si rv, N v, and CIII*, and about 0.26 dex for N IV*. For C rv, we can only derive an expression for the mean ionization fraction in the wind if the mass-loss rate is small, (M) over dot < 10(-6) M-. yr(-1), because the C N lines are usually saturated for higher mass-loss rates. The resulting expressions for T-rad can be used to derive the mass-loss rates from studies of ultraviolet P Cygni profiles in the range of stellar parameters studied here: 30,000 K less than or similar to T-eff less than or similar to 50,500 K, 5.2 less than or similar to log L/L-* less than or similar to 6.4, and - 7.5 M-. less than or similar to log (M) over dot less than or similar to -4.6 M-. yr(-1). An accuracy of about a factor of 2 or better can be reached, depending on the Lines that are used and the accuracy of the line fits and the stellar parameters. The Si Iv lines give the most reliable mass-loss rates, because the abundance is about the same for all O stars,the lines saturate only for high mass-loss rates, the doublet lines only partly overlap, and the mass-loss rate is proportional to the square root of the column density. The radiation temperature of N v shows a surprisingly strict relation with T-eff, with a scatter of only Delta T-rad/T-eff = 0.01. The mass-loss rate cannot be derived from the N v lines, because the column density of the N v ions in the wind is independent of (M) over dot. A consistency check and a test of the method for the stars HD 14749 and HD 190429 show that the mass-loss rate derived from the UV lines. with the ionization fractions of this paper agree very well with the mass-loss rate derived from new radio flux measurements.