Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser not getting the css-Class!? #68

Open
Meistercoach83 opened this issue Mar 30, 2017 · 1 comment
Open

Parser not getting the css-Class!? #68

Meistercoach83 opened this issue Mar 30, 2017 · 1 comment

Comments

@Meistercoach83
Copy link

Meistercoach83 commented Mar 30, 2017

Hi,

I´m trying to get the row´s css-Classes from this small html-snippet:

<div class="club-matches">
			<table class="table">
				<tbody>
					<tr class="row-mainInfo">
						<td colspan="6">Samstag, 26.08.2017 - 18:00 Uhr | CS:GO | Friendly</td>
					</tr>

my current code:

foreach($html('div.club-matches table tbody tr') as  $index => $row) {
            echo $index;
            echo $row->class;
            echo $row->getPlainText(), "<br>\n";
        }

My Problem: I can display the PlainText from each row - but not its css-Class.. what´s wrong with my code?

** edit:
When I do an

var_dump($row->attributes);

I get

array(1) {
  ["class"]=>
  string(26) "row-mainInfo"

}

@robneu
Copy link

robneu commented Mar 30, 2017

I also ran into this and had to resort to pulling it out of the attributes. It works, but definitely seems like a bug. This should work, I think:

foreach($html('div.club-matches table tbody tr') as  $index => $row) {
	$class = '';
	if ( isset( $row->attributes['class'] ) ) {
		$class = $row->attributes['class'];
	}

	echo $index;
	echo $class;
	echo $row->getPlainText(), "<br>\n";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants