ImportXML and <include>

Posted by Twisol on Tue 09 Feb 2010 09:10 AM — 1 posts, 5,093 views.

USA #0
I find myself wanting to use ImportXML() with an <include> tag in the passed text, to include a nominated XML file from script. I'm unable to place the <include> tag directly into the parent file because I want to be able to dynamically load an XML file sometime during runtime. However, due to the implementation of ImportXML, it ignores <include> tags if the passed content does not have an associated filename (that is, if it's from the clipboard or a scripted string).

I also can't use the io.* methods to open the file and pass the contents in that way, because (1) the io.* functions are disabled if the world/plugin isn't trusted, and (2) <include> tags within THAT content won't be processed either, due to the same issue.

According to a comment within ImportXML's source, it behaves this way so that XML imported from the ImportXMLDlg wouldn't cause the <include> tags to be evaluated. I suppose it's a valid concern, although IMO if someone wants to import an <include>, more power to them.


If possible, it would be nice to fix ImportXML itself. Given that you might not not want to change its behavior, though, would it be possible to add a new scripting function to fill the gap?