Creating new XMLFile programatically

Answered

I'm trying to create a new XMLFile and marshal the DomElement model that I have into it. Going through the forum and also the guides, it's assumed everywhere that I have the XMLFile (assuming by using PsiManager) and modifications happens afterwards. In my case, the file doesn't even exist and I don't see a way to create the XMLFile. 

So my question is this: if I want to create the XMLfile, do I have to first create the file and add the parent tag there and then read it using PsiManager? or there is a better way of doing this.

 

0
1 comment
Official comment

You can create the file from text (PsiFileFactory) and then use PsiDirectory.add for it to be saved to disk. Or you can do virtualFile.createChildData(this, "a.xml") directly.

Please sign in to leave a comment.