Xijing zaji 西京雜記 "Miscellaneous records of the Western Capital" is a collection of short semi-historiographical stories from the Former Han dynasty 前漢 (206 BCE-8 CE) court. At that time the capital was Chang'an 長安 in the west (the "Western Capital", modern Xi'an 西安, Shaanxi), while the Later Han dynasty 後漢 (25-220 CE) moved to Luoyang 洛陽 (modern Luoyang, Henan) further to the east. The compiler of the book is not known. The imperial bibliography in the official dynastic history Jiutangshu 舊唐書 names the Jin period 晉 (265-420) writer Ge Hong 葛洪 as the author, other sources, like Chao Gongwu's 晁公武 private bibliography Junzhai dushu zhi 郡齋讀書志 from the Southern Song period 南宋 (1127-1279), wrongly attribute the book to the Liang period 梁 (502-557) scholar Wu Jun 吳均. The bibliography Jingjizhi 經籍志 in the dynastic history Suishu 隋書 speaks of a length of 2 juan "scrolls", while other books talk of 1 or even 6 juan. According to the postface (xu 序) that was allegedly written by Ge Hong the sources for the Xijing zaji came from Liu Xin's 劉歆 collection of historiographical material that were also used for the compilation of the dynastic history Hanshu 漢書, but were not included in the history because of their rather novelistic content. The transmitted version of the Xijing zaji is a collection of material not used in the Hanshu. It is therefore traditionally classified as a collection of novellas (xiaoshuo 小說), and not as a historiographic book.
The Xijing zaji includes 129 stories which all took place in the capital Chang'an. Although most of the stories are of historiographical content, there are also some belonging to the genre of supernatural stories (zhiguai 志怪). Some of the stories became very popular and have found their way into higher forms of literature, like poetry and theatre. Among those are the story of princess Wang Zhaojun 王昭君 sent out to marry the Xiongnu khan; the love of the poetess Zhuo Wenjun 卓文君 to Sima Xiangru 司馬相如; how Kuang Heng 匡衡 made a hole in the wall to let in light for reading books; how Sima Qian 司馬遷, injustly punished by castration, decided to compile his universal history Shiji; how the philosopher Dong Zhongshu 董仲舒 explained the phenomena of frost, hail and snow as results of the effect of the cosmic forces Yin and Yang; the licentious behaviour of the sisters and imperial consorts Zhao Feiyan 趙飛燕 and Zhao Hede 趙合德; Jia Peilan's 賈佩蘭 intimate friendship with her mistress, Lady Qi 戚夫人; or the story of Qiu Hu 秋胡 who disguised himself as a women in order to escape military service. The tales of palace life contain a lot of information about the buildings of the Forbidden City, the adornments and clothes of the men and women living in it, or their customs and habits.
The Xijing zaji is often quoted in Li Shan's 李善 commentary to the literary anthology Wenxuan 文選, as well as in the Tang period 唐 (618-907) encyclopedia Chuxueji 初學記, which shows that the book was widely known in earlier ages. The language is vivid and colourful, but very simple and elegant.
The Xijing zaji is included in the reprint series Sibu congkan 四部叢刊, where a Ming period 明 (1368-1644) print is reproduced, Gujin yishi 古今逸史, Han-Wei congshu 漢魏叢書, Zengding Han-Wei congshu 增訂漢魏叢書, Baihai 稗海, Kuaige cangshu 快閣藏書, Jindai mishu 津逮秘書, Xuejin taoyuan 學津討源, Longwei mishu 龍威秘書, Yiyuan junhua 藝苑捃華, Siku quanshu 四庫全書 (all with the 6 juan version), in Guo Zizhang's 郭子章 Qin-Han tuji 秦漢圖記 (together with the book Sanfu huangtu 三輔黃圖), and the reprint series Baojingtang congshu 抱經堂叢書, Zhengjuelou congkan 正覺樓叢刻 and Longxi jingshe congshu 龍溪精舍叢書 (the last three with the 2 juan version). The Zhonghua shuju press 中華書局 has published a modern version in 1985 (with a commentary compiled by Cheng Yizhong 程毅中), and in 1991 the Shanghai guji press 上海古籍出版社 published a commented edition.