This is Exercise 9 from Section 34 of Munkres - Topology. Following the hint given, I've done the following:Since $X$ is compact, $X_1,X_2$ are compact metrizable and hence have countable bases. Let $\mathscr B_1$,$\mathscr B_2$ be countable collections of open sets in $X$ such that $\{B\cap X_1:B\in\mathscr B_1\},\{B\cap X_2:B\in\mathscr B_2\}$ are bases for $X_1,X_2$ respectively. Now let $$\mathscr A=\{X_1\setminus X_2,X_2\setminus X_1\}\cup\mathscr B_1\cup\mathscr B_2.$$
The idea, as suggested by the hint, is to show that $\mathscr A$ is a subbasis for the topology on $X$.
Let $U\subseteq X$ be open, and $x\in U$. If $x\in U\cap(X_1\setminus X_2)$, then there is a $B\in\mathscr B_1$ such that $x\in U\cap B\cap(X_1\setminus X_2)$. For $x\in U\cap(X_2\setminus X_1)$ there is a $B\in\mathscr B_2$ with $x\in U\cap B\cap (X_2\setminus X_1)$.
I'm stuck when $x\in U\cap X_1\cap X_2$. Picking $B_1\in\mathscr B_1,B_2\in\mathscr B_2$ such that $B_1\cap X_1\subseteq U\cap X_1$ and $B_2\cap X_2\subseteq U\cap X_2$, does not guarantee that $B_1\cap B_2\subseteq U$.
Use the fact that $X = X_1 \cup X_2$. Take $y \in B_1 \cap B_2$. Then $y \in X_i$ for some $i \in \{1,2\}$. But then $y \in B_i \cap X_i \subseteq U \cap X_i \subseteq U$. So in fact $B_1 \cap B_2 \subseteq U$.