Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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?

like image 401
Computer User Avatar asked Jun 16 '13 08:06

Computer User


2 Answers

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();
}
like image 164
CodigosTutoriales Avatar answered Nov 12 '22 00:11

CodigosTutoriales


If firefox or chrome are not a strict requirement, I suggest geany, in particular its pretty-printer plugin. With it you can simply format the file in a human-friendly way, fold and un-fold all elements in a single click and so on.

If you are on debian or ubuntu:

sudo apt-get install geany geany-plugin-prettyprinter
like image 29
mrfree Avatar answered Nov 12 '22 01:11

mrfree