开发者

Populating jsTree based on XML data uploaded to server folder

开发者 https://www.devze.com 2023-02-02 11:39 出处:网络
tl:dr How can I populate jsTree based on a folder location instead of an exact XML url? I\'m looking for a little direction on this project.

tl:dr How can I populate jsTree based on a folder location instead of an exact XML url?

I'm looking for a little direction on this project.

Currently I am trying to copy file structures of hard drives as XML files and recreate them using jsTree on the webserver for a completely independent version of the file structure. I have some python script that outputs XML files that are formed to jsTree and automatically uploads to a folder on the server. The problem is now I am a little lost because I have to manually enter each XML file into jsTree code for it to display so I have multiple entries like this:

 $("#tree1")
   .jstree({ 
       "plugins" : [ "themes", "xml_data", "ui", "search", 开发者_StackOverflow社区"types" ],
        "xml_data" : {      
            "ajax" : {
                "url" : "./XML_DATA/DRIVE1.xml"
                     },
                        "xsl" : "nest" 
                     },

I see in the documentation that instead of populated by the direct file the folders are populated by "server.php" but no where in the php code does it point to any directories or files. After considering the problem I thought of a few solutions and could use some advice on them:

Should I be trying to write php code to automatically look through my XML_DATA folder to upload each XML file? Should I just upload all the XML to mySQL and populate my tree based on that? Should the javascript be the code looking through the server's folder for XML files?

All the XML is formed the same way but the number of XML files on the server will increase and will have to be refreshed as well as they will be overwritten with changes. Any direction would be appreciated, thanks.


What functions of jstree are you trying to use?

If you're just wanting to have an expandable tree matching what's on your filesystem. Then you can either point to a php page that reads your file structure and outputs an <UL><LI> based tree and then apply jstree to it.

But since it sounds like you already wrote the XML generator in python, why not just add python support to your webserver, and serve up that XML file to the jstree instance?

The last worst option is to simply point to the generated XML file on your webserver. You won't have any dynamic abillity, but you'll get the XML file in jstree.

0

精彩评论

暂无评论...
验证码 换一张
取 消