I want to take the next sibling to a structure but I can't get it, taking into account that I have the following:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div class="row list-items">
<!-- Elemento que toma actualmente -->
<div class="col-md-12">
<div class="update-nag">
<div class="update-split">
<i class="glyphicon glyphicon-refresh"></i>
</div>
<div class="update-text">
Lorem ipsum
<a href="#">Lorem</a>
</div>
</div>
</div>
<!-- Elemento que hermano siguiente -->
<div class="col-md-6">
<div class="update-nag">
<div class="update-split">
<i class="glyphicon glyphicon-refresh"></i>
</div>
<div class="update-text">
Lorem ipsum
<a href="#">Lorem</a>
</div>
</div>
</div>
<div class="col-md-6">
<div class="update-nag">
<div class="update-split">
<i class="glyphicon glyphicon-refresh"></i>
</div>
<div class="update-text">
Lorem ipsum
<a href="#">Lorem</a>
</div>
</div>
</div>
</div>
</div>
My XPATH path that takes the first element is:
//div[contains(@class, "list-items")]//div[@class="col-md-12"]
and I would like to be able to grab the next node, with something like:
//div[contains(@class, "list-items")]//div[@class="col-md-12"]//next-sibling
Can such a thing be done? How do I do it?
try with axis
following-sibling
So:
You can't get what you want from the route you use in the question, because the result of that route contains only elements of the class,
col-md-12
and the sibling you want to fetch is not part of that collection.My suggestion is to start from this route:
This returns all the elements
div
that are direct children oflist-items
, and use it as an array.So
It returns the first element of said array, which is the
<!-- Elemento que toma actualmente -->
Y
It would be the
<!-- Elemento que hermano siguiente -->
, which is the one you want to find.