Reputation: 43
<span class="p_txt1 p_1">
<input type="checkbox" value="value 1">
<b>value 2</b>
</span>
<span class="p_txt1 p_1">
<input type="checkbox" value="value 1">
<b>value 2</b>
</span>
<span class="p_txt1 p_1">
<input type="checkbox" value="value 1">
<b>value 2</b>
</span>
i am trying to get value 1 from input and value 2 from bold tag but its not working
$doc = new DOMDocument();
@$doc->loadhtml($contents);
$xpath = new DOMXPath($doc);
$dataString = "";
$fruits = $xpath->query("//span[@class='p_txt1 p_1']");
foreach($fruits as $fruit) {
echo $xmlDate = $fruit->getElementsByTagName( "b" ),"<br>";
}
can anybody help
Upvotes: 2
Views: 63
Reputation: 1993
Try this:
$doc = new DOMDocument();
@$doc->loadhtml($contents);
$xpath = new DOMXPath($doc);
$dataString = "";
$fruits = $xpath->query("//span[@class='p_txt1 p_1']");
foreach($fruits as $fruit) {
foreach ($fruit->getElementsByTagName( "b" ) as $xmlBold) {
echo $xmlBold->nodeValue.'<br/>';
}
}
Upvotes: 1