If you check the XML for single GraphBuilderGroupBox you can see that you are looking for the value from XML
"<GraphBuilderGroupBox width=\!"570\!" height=\!"24\!" selected=\!"true\!">age = 12</GraphBuilderGroupBox>"
And you can get that value using XPath
gbb_texts = (Report(gb) << XPath("(//GraphBuilderGroupBox/text())"));
// {"age = 12", "age = 13", "age = 14", "age = 15", "age = 16", "age = 17"}
And if you just want to get the first one, you can limit the index already in XPath (like you have done) and then take first index from that as << XPath will return a list (I would most likely skip XPath index in this case, as you still have to use JMP's index)
gbb_text = (Report(gb) << XPath("((//GraphBuilderGroupBox/text()))[1]"))[1];
// or gbb_text = (Report(gb) << XPath("(//GraphBuilderGroupBox)[1]/text()"))[1];
with just JMP index
gbb_text= (Report(gb) << XPath("//GraphBuilderGroupBox/text()"))[1];
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Show Control Panel(0),
Variables(X(:weight), Y(:height), Page(:age), Overlay(:sex)),
Elements(Points(X, Y, Legend(9)), Line Of Fit(X, Y, Legend(11)))
);
group_texts = (Report(gb) << XPath("//GraphBuilderGroupBox/text()"));
// {"age = 12", "age = 13", "age = 14", "age = 15", "age = 16", "age = 17"}
-Jarmo