Search code examples
xmlgoogle-chrome-extensionxml-parsingfirefox-addonxml-visualizer

"collapse all" all nodes in one click in firefox or chrome


Any way to "collapse all" all nodes in one click in firefox or chrome and then able to search a node's name and then quickly see its path/tree of parent nodes? First collapse not just top node, but all child nodes, and when I search for a node then it opens only that tree of nodes. I want this because I search a node in a big xml file. The node is present many times under different paths of parent nodes and I need to see the path of the node where ever it appears. Right now I have to manually traverse whole file and collapse many times to find all paths of that node that is present many times in a file. Any quick way of doing it?


Solution

  • To collapse all XML nodes in Chrome, execute this in your JavaScript console

    var nodes = document.getElementsByClassName("button collapse-button");
    for (var i = 0; i < nodes.length; i++) {
        nodes[i].click();
    }