The analytical method of local environment of dilutely doped magnetic elements in functional materials in an atomic scale by the X-ray absorption near-edge structure (XANES) measurements and the first-principles calculations is demonstrated. Results for the lead-free piezoelectric material, Mn and Fe doped Bi4Ti3O12, is shown as an application of the above method.