Q:

Selenium XPATH having found the child div tag how to go up to the parent tag which contains your text parameter

I have a html page with some nested div tags.  The tags do have an ID but it is not a fixed value.  It changes as users add and delete items on the page.
The best way to locate the element I am looking for is by text.
Each parent has the Text "Clean" - Cannot locate from here as it is not unique.
Each parent has a child, the end part of the text in the child is different.
E.g. The text is "Clean feed crm" or "Clean feed escr" and so on
E.g. Parent "Clean" -> child "Clean feed crm"
Parent "Clean" -> child "Clean feed escr"
I would like to find the Parent tag the text "Clean" from the child "Clean feed escr"
From the html sample below it's current ID is id="operations_edit_process_list_task_4
But this ID will change so i cannot use the ID to get to this element.
I can locate the child "Clean feed escr" using XPATH.  I do not know how to go up the tags to get the "Clean" text
My XPATH is:
//span[contains(text(), "Clean feed escr")]

The HTML sample is (I have removed some div tags, it will be too long to paste otherwise)
<div id="operations_edit_process_list_task_3">
    <span>
        <span class="myinlineblock" title="Clean" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;width:100%;">Clean</span>
    </span>
    <span/>
    <span>
</div>
// Few More div tags

<div id="operations_edit_process_list_task_3_1">
    <span>
        <span class="myinlineblock" title="Clean feed escr" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;width:100%;margin-right:-14px;">Clean feed escr</span>
    </span>
    <span>
</div>
// Few More div tags

<div id="operations_edit_process_list_task_4">
    <span>
        <span class="myinlineblock" title="Clean" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;width:100%;">Clean</span>
    </span>
    <span/>
    <span>
</div>
// Few More div tags

<div id="operations_edit_process_list_task_4_1">
    <span>
        <span class="myinlineblock" title="Clean feed orchard" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;width:100%;margin-right:-14px;">Clean feed orchard</span>
    </span>
</div>

I think ancestor could be used t get to it's immediate parent tag but i do not know it's syntax.
I have tried the following:
//span[contains(text(), "Clean feed escr")]//ancestor::div[contains(text(), "Clean")]

Thanks,
Riaz

A:

With the help of the suggestions below I have managed to locate the element using the Preceding axis.  Preceding because I want to go up the tree to it's parent.  Not the 'following' axis.  following goes down the tree to it's children.
The Xpath is:
//div[.//span/text()='Clean feed escr']/ancestor::div[1]/preceding::div[1]//span[@title="Clean"]

