1. Install the below extension in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=VignaeshRamA.sfdx-package-xml-generator
2. Pres Ctrl + Shift + P.
3. Enter package and select Package.xml Generator: Choose Metadata Components.
4. Choose Metadata Components for Package.XML.
5. Click Update Package.xml button to update the package.xml file.