We can test the elements and their immediate elements using CSS.
If your element is in this format.
<span id="firstChild">first child <a>second child</a></span>
String str = selenium.getText("css=div#combinatorTest > span");
String str = selenium.getText("css=div#combinatorTest > span>a");
<a class="class1 class2 class3">this is the element</a>
You can use below code for verifying the element or storing the text in the element.
Verifying element in RC
verifyTrue(selenium.isElementPresent("css=a[class~=\"class2\"]"));
Verifying element in IDE
<tr>
<td>verifyElementPresent</td>
<td>css=a[class~="class2"]</td>
<td></td>
</tr>
storing element text in a variable using RC
String str = selenium.getText("css=a[class~=\"class3\"]");
storing element text in a variable using IDE
<tr>
<td>storeText</td>
<td>css=a[class~="class3"]</td>
<td>str</td>
</tr>
<div id="combinatorTest">this is the parent element. <span id="firstChild">this is a child element <a>and grandson element</a></span>, <span>another child element</span>, <span>last child element<span></span></span></div>
How to store the text of preceding combinator element in RC to store "another chile element"
String str = selenium.getText("css=span#firstChild + span");
to store "last child element"
String str = selenium.getText("css=span#firstChild + span + span");
How to store the text of preceding combinator element in IDEto store "another chile element"
<tr>
<td>storeText</td>
<td>css=span#firstChild + span</td>
<td>str</td>
</tr>
to store "last child element"
<tr>
<td>storeText</td>
<td>css=span#firstChild + span + span </td>
<td>str</td>
</tr>