This article illustrates the method of jquery parsing XML file dynamically adding JS file at the same time. Share to everyone for your reference. The implementation methods are as follows:
$ (function () {
$.ajax ({
URL: ' js/config/jsconfig.xml ',
dataType: ' xml ',
success:function (data) {
$ (data). Find ("ModuleName"). each (function (i,obj) {
var field = $ (this);
var funcName = field.attr ("name");
for (var i = 0;i < Field.find ("func"). Size (); i++) {
var func = Field.find ("Func:eq (" + i + ")"). text ();
var src = ' <script type= ' text/javascript ' src=\ ' + func + '. Js\ "></script>";
$ ("Body"). Append (src);}});}}
<?xml version= "1.0" encoding= "UTF-8"?>
<module>
<modulename name = "Admin" >
<func >js/module/testXml</func>
<func>js/module/device</func>
</moduleName>
</module>
I hope this article will help you with your jquery programming.