Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default xml tree parsing

    hi

    i need to parse a tree structure definited in a xml document...dow you can
    find a simple part...but structure is much longer with several levels.

    every level must know his "sons" and not whole tree below it..


    can u help me parsing it? it's very important.

    Thx so much.


    *********************
    <?xml version="1.0"?>
    <tree>
    <level>
    <name>Project doc1</name>
    <files>doc di progetto1</files>

    <level>
    <name>secondo liv2</name>
    <files>secondofiles2</files>
    <level>
    <name> liv3</name>
    <files>liv3</files>
    <level>
    <name> liv4</name>
    <files> liv44</files>
    </level>
    </level>
    <level>
    <name>secondo liv33</name>
    <files>secondofiles33</files>
    </level>
    </level>

    <level>
    <name>secondo liv2</name>
    <files>secondofiles2</files>
    </level>
    </level>
    </tree>
    Hetfield Guest

  2. Similar Questions and Discussions

    1. XML::DOM parsing pb
      Hi, I have a simple parsing problem (I know it is simple but I just started with XML::DOM) that I do not know how to resolve : here is the xml...
    2. About XML tree
      Hi I want to know about height of content because I want to move box below the tree menu (last menu) so I see if tree is over than that we create...
    3. tree
      i want to add a node in a specific place after serching a specific node name can it be done note i try to serch a specific node whith the method...
    4. Pod-Tree
      Hi, i have to perform the simple (!!!) task of generating the HTML doc out of a code distro. So i'm trying to make sense of pod2html, but i don't...
    5. Pod::Tree
      Hey all, I wanna implement a weighted tree in perl, Pod::Tree looks like it'll help, but what's POD actually stand for? And are they are any...
  3. #2

    Default Re: xml tree parsing

    On Mon, 01 Dec 2003 17:08:31 GMT, Hetfield <hetfield@email.it> wrote:
    >i need to parse a tree structure definited in a xml document
    [url]http://php.net/xml[/url]

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  4. #3

    Smile Re: xml tree parsing

    <head>
    <title>Treeview</title>
    <link rel="stylesheet" href="style.css" type="text/css" />
    <script type="text/javascript" src="js/jquery-1.6.1.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript" src="js/jquery.treeview.js"></script>
    </head>
    <body>

    <div>
    <ul id="browser">
    <?php
    $filename = new DOMDocument();
    $filename->load('test.xml');

    $students = $filename->getElementsByTagName("level");
    foreach( $students as $student )
    {
    $stu = $student->localName;
    $names = $student->getElementsByTagName("name");
    $name = $names->item(0)->nodeValue;

    $files = $student->getElementsByTagName("files");
    $file = $files->item(0)->nodeValue;
    echo "
    <li class='closed'>".$stu."
    <ul><li>".$name."</li>
    <li>".$file."</ul></li>";
    }
    ?>
    </ul>
    </div>

    <script type="text/javascript">
    $(document).ready(function(){
    // ---- TREE -----
    $("#browser").treeview();
    $("#navigation").treeview({
    persist: "location",
    collapsed: true,
    unique: true
    });
    // ---- TREE -----
    });
    </script>
    </body>
    Armenia Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139