P
Patrick Spence
Tree view displayed on web page looks like this:
Smoking
Survey & Feedback
Depression
Survey & Feedback
Stress Management
Survey & Feedback
Weight Management
Exercise
Survey & Feedback
Healthy Eating
Survey & Feedback
Managing Emotions
Survey & Feedback
Using the "className" property of each node, I am able to
determine the hierarchy. After scraping the list of nodes
from the page, I have an array that contains the following:
[
[ 1, "Smoking", "root" ],
[ 2, "Survey & Feedback", "leaf" ],
[ 3, "Depression", "root" ],
[ 4, "Survey & Feedback", "leaf" ],
[ 5, "Stress Management", "root" ],
[ 6, "Survey & Feedback", "leaf" ],
[ 7, "Weight Management", "root" ],
[ 8, "Exercise", "parent" ],
[ 9, "Survey & Feedback", "leaf" ],
[10, "Healthy Eating", "parent" ],
[11, "Survey & Feedback", "leaf" ],
[12, "Managing Emotions", "parent" ],
[13, "Survey & Feedback", "leaf" ]
]
What I need to do is iterate thru each element of the array,
determining the parent and root nodes of each element,
separating each level of the hierarchy with a pipe symbol.
The end result would be an array that contains something
like this:
[
["Smoking|Survey & Feedback"]
["Depression|Survey & Feedback"]
["Stress Management|Survey & Feedback"]
["Weight Management|Exercise|Survey & Feedback"],
["Weight Management|Healthy Eating|Survey & Feedback"],
["Weight Management|Managing Emotions|Survey & Feedback"]
]
Anyone got any ideas on this?
TIA
Smoking
Survey & Feedback
Depression
Survey & Feedback
Stress Management
Survey & Feedback
Weight Management
Exercise
Survey & Feedback
Healthy Eating
Survey & Feedback
Managing Emotions
Survey & Feedback
Using the "className" property of each node, I am able to
determine the hierarchy. After scraping the list of nodes
from the page, I have an array that contains the following:
[
[ 1, "Smoking", "root" ],
[ 2, "Survey & Feedback", "leaf" ],
[ 3, "Depression", "root" ],
[ 4, "Survey & Feedback", "leaf" ],
[ 5, "Stress Management", "root" ],
[ 6, "Survey & Feedback", "leaf" ],
[ 7, "Weight Management", "root" ],
[ 8, "Exercise", "parent" ],
[ 9, "Survey & Feedback", "leaf" ],
[10, "Healthy Eating", "parent" ],
[11, "Survey & Feedback", "leaf" ],
[12, "Managing Emotions", "parent" ],
[13, "Survey & Feedback", "leaf" ]
]
What I need to do is iterate thru each element of the array,
determining the parent and root nodes of each element,
separating each level of the hierarchy with a pipe symbol.
The end result would be an array that contains something
like this:
[
["Smoking|Survey & Feedback"]
["Depression|Survey & Feedback"]
["Stress Management|Survey & Feedback"]
["Weight Management|Exercise|Survey & Feedback"],
["Weight Management|Healthy Eating|Survey & Feedback"],
["Weight Management|Managing Emotions|Survey & Feedback"]
]
Anyone got any ideas on this?
TIA