Nice Question , For this situation we will count the avalable row in web page, Lets see a example of <ul> and <li>
here li are dynamic see this example.
int size = driver.findElements(By.xpath("//*[@id='demo_ID']/ul/li")).size();
NOTE : here you need to use findElemets not findElemet .
for(int i=1;i<=size;i++){
WebElement text = driver.findElement(By.xpath("//*[@id='demo_ID']/ul/li["+i+"]/div[4]/p[3]/span[1]"));
String strGetContent = text.getText();
System.out.println(strGetContent);
}
Here we will get the all available row's content in web page, I hope you got my point , if you have any problem so let me know.