Question: I have the following document:

```
<a>
  <bb>abc</bb>
  <cc>ccc</cc>
  <dd>ddd</dd>
</a>
<a>
  <bb>zz</bb>
  <cc>1</cc>
  <dd>2</dd>
</a>

```

How can I get the value of `<cc>` using XPath if `<bb>` is `zz`?

Answer: 
What you need is `following-sibling` XPath axis

```
//a/bb[text()="zz"]/following-sibling::cc[1]/text()

```

Test the Xpath here: <http://www.xpathtester.com/obj/b55ec3ac-dfa4-4f44-81e8-f963ea4a0625>
First off, your example is not well-formed XML. Overlooking that and that you didn't describe your intents very well (What exactly do you want to select on which condition?), I assume you want to do this:

```
//cc[preceding-sibling::bb[text()="zz"]]/text()

```

It selects

```
TEXT VALUES OF ALL <CC> ELEMENTS
//cc                                    /text()
    THAT HAVE A PRECEDING SIBLING <BB>
    [preceding-sibling::bb             ]
                          THAT HAS TEXT VALUE EQUAL TO "zz"
                          [text()="zz"]

```

You could write is also as

```
//bb[text()="zz"]/following-sibling::cc/text()

```

Please look at [the spec](http://www.w3.org/TR/xpath/), it has some very well readable [examples](http://www.w3.org/TR/xpath/#path-abbrev) from which you'll learn a lot.