Importing an external XML file into project.

I am using Xojo 2014 Release 3.2 and I am currently working on an application that makes use of some data in an XML file. I don’t really want this XML file to be external to the application, as I don’t want it tampered with, so I was hoping to just drop it into my project and read it from there. However, when I attempt to do this (or use File > Import) I get the error message “File Foo.xml could not be imported”. I’m able to import other file types without a problem, and I have managed to import my XML file by changing its extension to .txt - but that doesn’t feel right to me. Is this a bug with the IDE or am I doing something wrong? Any help would be much appreciated.

The IDE interprets .xml files as code and tries to import it as such (XML is one of the supported formats you can save your project, or portions of your project, to). Changing the extension is the right way to get around it.

Thank you for the explanation, Tim. I don’t think changing the extension is the right way to get around this problem personally - the IDE should be intelligent enough to know that I’m just importing a regular XML file rather than a project XML file - but I’ll roll with it for now. :slight_smile:

Then how would the IDE know what you dragged into the project is not a class saved in XML format ? Likewise, in iOS, plist files are used for certain operations, and the IDE has no way to know your intent when you drag a plist into the project.

Renaming the file is one valid way.

The other one, on Mac at least, is to use a copyfile to put the file in the bundle, and then access it from the program as such. But it is yet more convoluted than a simple file rename…