Gojs.net ->samples -> DOMTree only display certain elements / change root

Hi, I use the https://gojs.net/latest/samples/DOMTree.html to visualize my DOM tree and I have a few questions:

How can I only display certain elements like : only

tags and only with a certain class or ID

How can I change the root of the Graph from the BODY tag to a

tag with a certain ID / class

Change the traverseDOM function to only include those elements that you want.

See Gojs.net -> samples -> DOM Tree : Update Graph after new elements are insert

You’ll note that that sample’s traverseDom function is already filtering out elements from the DOM. You can modify the function to filter out whatever you like.

You can call the updated traverseDom function with whatever root element you like.