usage of near child (> operator) not working
scorninpc opened this issue · 1 comments
scorninpc commented
What is this feature about (expected vs actual behaviour)?
When find for > span
for example, throw a error Expected selector, but " at 0> found.
In the code above, first echo show real 29.30 nodes
fine, but second one need to return just 29.30
How can I reproduce it?
$find = (new \voku\helper\HtmlDomParser())->loadHtml(<<<EOD
<html>
<body>
<div class="card-action-item"></div>
<div class="card-action-item">
real <span>29.30</span> <span> nodes</span>
</div>
</body>
</html>
EOD);
$find = $find->find(".card-action-item:nth-child(2)", 0);
$all = $find->text;
echo $all . "\n";
$find = $find->find("> span");
$just_value = $find->text;
echo $just_value . "\n";
Any additional information?
I have tested on another languages, and this may be a valid selector. am I doing something wrong?
scorninpc commented
As we can use xpath to create a selector too, enable axes can help (#103)
with this change, we can use something like this
$find = (new \voku\helper\HtmlDomParser())->loadHtml(<<<EOD
<html>
<body>
<div class="card-action-item"></div>
<div class="card-action-item">
real <span>29.30</span> <span> nodes</span>
</div>
</body>
</html>
EOD);
$find = $find->find(".card-action-item:nth-child(2)", 0);
$all = $find->text;
echo $all . "\n"; // print real 29.30 nodes
$find = $find->find("child::span");
$just_value = $find->text;
echo $just_value . "\n"; // print 29.30
if @voku accept the idea, i can implement another ones https://www.w3schools.com/xml/xpath_axes.asp