A wxs file is just XML. You can edit it in your application with any XML API. In .NET, you can do this by loading the file in a System.Xml.XmlDocument or System.Xml.Linq.XDocument.
Alternatively, you can use the heat.exe tool included in wix to "harvest" (i.e. generate a wxs file for) individual files or an entire folder. This doesn't allow you to edit a wxs file exactly, but that is not a problem because a wix setup can consist of multiple wxs files.
From the heat.exe documentation:
Harvest a file
heat file -ag -template:fragment -out file.wxs ".\My Files\File.dll"
This will harvest the file "File.dll"
as a single fragment to the file
file.wxs. The component guid will be
set to "*".