Solved

searching directories from xml nodes click value

Posted on 2008-06-11
5
215 Views
Last Modified: 2013-12-13
Hello every one
  i am trying to create some function which does the following, it maight be a bit tricky i think so please any idea or help please????
     The Question is

     i have created tree from xml file using java script and php, the name of the nodes are the (string that i want to search) same as to the search string, so, when some one click the node, how can i be able to search the clicked string against some other folder which contains subfolders and files which (it is so important)the file names is so long and include the path of the tree and include the nodes name???

     example  
        i have tree like   AAA
                                    ¦
                                   bbb
                                     ¦
                                    ccc
                                   
and all the files in the folder are by the name like
      AAA____________bbb____________ccc____________ddd____________25125425_62532512.txt  or other extension like .bin or .log...... And this file is kept under the folder called (ddd).
     so if some one click on the node ccc how could i able to search from some folder which include many subfolders to match the name AAA____________bbb____________ccc and if the file has this name show the file.???

Please i really need help, i am just stake and preparing to through my self to sea; Help???
to clarify it more..I have the following code. some XML File ..and i got the tree using php. the xml file and the tree menu are
 
<?xml version='1.0' encoding='UTF-8'?>
<cstSta xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  >
    <cfgVersion>
        <major>1</major>
        <release>0</release>
        <update>0</update>
        <evolution>0</evolution>
    </cfgVersion>
    <uicCstData>
        <uicCstLbl>testCst</uicCstLbl>
        <operator>0</operator>
        <owner>0</owner>
        <nationalAppl>0</nationalAppl>
        <nationalVers>0</nationalVers>
        <properties>00000000000000000000000000000000000000000000</properties>
    </uicCstData>
    
    <vlan>
        <id>1</id>
        <gateway>10.0.0.1</gateway>
        <uniCast>
            <netAddr>10.0.0.0</netAddr>
            <subNetMsk>255.255.240.0</subNetMsk>
        </uniCast>
        <multiCast>
            <netAddr>239.0.0.0</netAddr>
            <subNetMsk>255.255.240.0</subNetMsk>
        </multiCast>
        <broadcastAddr>10.0.15.255</broadcastAddr>
    </vlan>
    <switchCfgEntry>
        <switchCfgIndex>1</switchCfgIndex>
        <dhcpRelay>true</dhcpRelay>
        <igmp>
            <mCastStop>false</mCastStop>
            <autoMode>true</autoMode>
            <querier>false</querier>
        </igmp>
        <rstp>
            <rstpRoot>false</rstpRoot>
        </rstp>
    </switchCfgEntry>
    <portCfgEntry>
        <static>
            <index>1</index>
            <vlanMemberId>1</vlanMemberId>
            <vlanTagged>false</vlanTagged>
            <portQoS>false</portQoS>
            <priority>0</priority>
            <speed>AUTO</speed>
            <portIsolation>false</portIsolation>
            <rstpTrunk>false</rstpTrunk>
            <igmpTrunk>false</igmpTrunk>
            <wanPort>false</wanPort>
        </static>
        <dynamic>
            <index>2</index>
            <portQoS>false</portQoS>
            <priority>0</priority>
        </dynamic>
    </portCfgEntry>
    <dhcp>
        <active>true</active>
        <globalConfig>
            <vlanMemberId>1</vlanMemberId>
            <leaderDevNo>0.0.0.1</leaderDevNo>
            <configUnknownClients>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <vlanMemberId>1</vlanMemberId>
                <leaderRange>
                    <firstDevNo>0.0.0.201</firstDevNo>
                    <lastDevNo>0.0.0.210</lastDevNo>
                </leaderRange>
                <followerRange>
                    <firstDevNo>0.0.0.211</firstDevNo>
                    <lastDevNo>0.0.0.220</lastDevNo>
                </followerRange>
                <defaultLeaseTimeSec>300</defaultLeaseTimeSec>
                <maxLeaseTimeSec>600</maxLeaseTimeSec>
                <minLeaseTimeSec>60</minLeaseTimeSec>
            </configUnknownClients>
            <defaultLeaseTimeSec>259200</defaultLeaseTimeSec>
            <maxLeaseTimeSec>259200</maxLeaseTimeSec>
            <minLeaseTimeSec>60</minLeaseTimeSec>
            <declineTimeSec>10</declineTimeSec>
            <conflictTimeSec>30</conflictTimeSec>
            <offerTimeSec>30</offerTimeSec>
            <ping>
                <alwaysCheck>false</alwaysCheck>
                <timeoutSec>1</timeoutSec>
            </ping>
            <loggingLevel>DEBUG</loggingLevel>
            <logConsole>true</logConsole>
            <logFile>false</logFile>
        </globalConfig>
        <options>
            <vlanMemberId>1</vlanMemberId>
            <domainNameSvr>0.0.0.1</domainNameSvr>
            <ipDefaultTimeToLive>30</ipDefaultTimeToLive>
            <interfaceMTU>1500</interfaceMTU>
        </options>
    </dhcp>
 
    <carSta>
        <uicCarData>
            <uicIdentifier>0</uicIdentifier>
            <properties>000000000000</properties>
        </uicCarData>
        <iptCarData>
            <cstCarNo>1</cstCarNo>
            <carId>car01</carId>
            <hasCstOrientation>true</hasCstOrientation>
            <carType>V1</carType>
        </iptCarData>
        <groups>
            <grpNo>0.0.1.0</grpNo>
            <grpLbl>grpAll</grpLbl>
        </groups>
        <switch>
            <type>DR</type>
            <hostLbl>RS1</hostLbl>
            <devNo>0.0.0.1</devNo>
            <vlanMemberId>1</vlanMemberId>
            <switchCfgIdx>1</switchCfgIdx>
            <port>
                <portNo>X2</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X3</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X4</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X5</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X6</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X7</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X31</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X32</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.10</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>MCG_1</devLbl>
                    <dhcpLbl>MCG_1</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.11</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>EDSERVICE_1</devLbl>
                    <dhcpLbl>EDSERVICE_1</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.12</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>CLIENT_1</devLbl>
                    <dhcpLbl>CLIENT_1</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
        </switch>
    </carSta>
     <carSta>
        <uicCarData>
            <uicIdentifier>0</uicIdentifier>
            <properties>000000000000</properties>
        </uicCarData>
        <iptCarData>
            <cstCarNo>1</cstCarNo>
            <carId>car02</carId>
            <hasCstOrientation>true</hasCstOrientation>
            <carType>V1</carType>
        </iptCarData>
        <groups>
            <grpNo>0.0.1.0</grpNo>
            <grpLbl>grpAll</grpLbl>
        </groups>
        <switch>
            <type>DR</type>
            <hostLbl>RS1</hostLbl>
            <devNo>0.0.0.1</devNo>
            <vlanMemberId>1</vlanMemberId>
            <switchCfgIdx>1</switchCfgIdx>
            <port>
                <portNo>X2</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X3</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X4</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X5</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X6</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X7</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X31</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X32</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.10</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>MCG_2</devLbl>
                    <dhcpLbl>MCG_2</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.11</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>EDSERVICE_2</devLbl>
                    <dhcpLbl>EDSERVICE_2</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.12</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>CLIENT_2</devLbl>
                    <dhcpLbl>CLIENT_2</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
        </switch>
    </carSta>
     <carSta>
        <uicCarData>
            <uicIdentifier>0</uicIdentifier>
            <properties>000000000000</properties>
        </uicCarData>
        <iptCarData>
            <cstCarNo>1</cstCarNo>
            <carId>car03</carId>
            <hasCstOrientation>true</hasCstOrientation>
            <carType>V1</carType>
        </iptCarData>
        <groups>
            <grpNo>0.0.1.0</grpNo>
            <grpLbl>grpAll</grpLbl>
        </groups>
        <switch>
            <type>DR</type>
            <hostLbl>RS1</hostLbl>
            <devNo>0.0.0.1</devNo>
            <vlanMemberId>1</vlanMemberId>
            <switchCfgIdx>1</switchCfgIdx>
            <port>
                <portNo>X2</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X3</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X4</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X5</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X6</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X7</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X31</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <port>
                <portNo>X32</portNo>
                <staticCfgIdx>1</staticCfgIdx>
            </port>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.10</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>MCG_3</devLbl>
                    <dhcpLbl>MCG_3</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.11</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>EDSERVICE_3</devLbl>
                    <dhcpLbl>EDSERVICE_3</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
            <deviceGroup>
                <dynamicCfgIdx>2</dynamicCfgIdx>
                <device>
                    <devNo>0.0.1.12</devNo>
                    <vlanMemberId>1</vlanMemberId>
                    <devLbl>CLIENT_3</devLbl>
                    <dhcpLbl>CLIENT_3</dhcpLbl>
                    <leaseTime>259200</leaseTime>
                </device>
            </deviceGroup>
        </switch>
    </carSta>
  
</cstSta>
___________________________________________________________
 
     <?php
            echo "<br />";
            echo "<a href=\"javascript:Tmenu.flatten('Menu', 'expand')\">Expand All</a> | 
                                                        <a href=\"javascript:Tmenu.flatten('Menu', 'contact')\">Collaps All</a>";
                                                  
            $Bws = simplexml_load_file('bws.xml');
                                                        
                                                        
            foreach($Bws->uicCstData as $uicCstData) {
                echo "<ul id=\"Menu\" class=\"Tshow\">";
                echo "<li>".$uicCstData->uicCstLbl;
                echo "<ul rel =\"open\">";
                                                             
                foreach($Bws->carSta as $carSta) {
                                                            
                    echo "<li>".$carSta->iptCarData->carId;
                    echo "<ul>";
                                                            
                    foreach($carSta->switch->deviceGroup as $deviceGroup) {
                                                                     
                        echo  "<li><a href=\"files.php\" target=\"frame1\">".$deviceGroup->device->devLbl."</a></li>";
                                                               
                       
                        }
                        echo "</li>";  
                        echo "</ul>";   
                    }
                                                     
                    echo "</ul>";
                    echo "</li>";  
                    echo "</ul>";    
                }
                                                
                                                        
                echo "<script type=\"text/javascript\">Tmenu.buildMenu(\"Menu\", false)</script>";
                                                        
            ?>
 
 so know when i get the tree i try to make clickable link linke this line 
 echo  "<li><a href=\"files.php\" target=\"frame1\">".$deviceGroup->device->devLbl."</a></li>";
 
but the thing which i need to do is when i click the link it take the value of ($deviceGroup->device->devLbl) and search the file which include the string that i click in its name against some directory on the server and dispay only the folder not the files it self.
 
     the file structure look like directory/subdirectory , that means i need to list the subdirectories if they contain file which its name contain the string that i click on the menu tree.
 
   the file name look like this..
 z5067__________car03__________CLIENT_2_______cccM___________098874_065210.txt
 
the file has more than 73 character and the first node which is always one on the tree is z5067__________,  but the next may be more than one car, like car03__________ the next  CLIENT_2_______ and the folder which the file reside is cccM___________ the numbers are just generated time,
 
So, please can i ahve some idea how can i be able to identify which node is clicked and check its path to the name of the file in the subdirectopry, and if found show the subfolder as clickable link.  is that makes sense???? ohhhhh Please

Open in new window

0
Comment
Question by:saad220
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 

Author Comment

by:saad220
ID: 21761237
I am really looking any idea Please???
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21773224
Doesn't it make your life easier to not use the unusual amounts of underscores in your filenames, but just use a directory structure on your filesystem as well? Besides the structuring impact it will increase your search performance heavily.
0
 

Author Comment

by:saad220
ID: 21775778
the problem is i can't change it the file name, because it is some how generated file names, not i give them like this difficult name. so how can i solve it programaticall, any idea coding, or let me if there is some similar tutorial out there
0
 

Accepted Solution

by:
saad220 earned 0 total points
ID: 21811234
I finally found out from other developer, here around me. But i am not happy for the expert comments, it wasn't satisfactory to me at all.
0

Featured Post

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question