Skip to content

Add a table parser for any arbitrary repeating HTML structure #2

Description

@acoulton

For example, to parse list-groups or other repeating multi element structures from a Mink NodeElement.

eg to get from:

<div class="list-group-item">
  <div class="list-group-item-heading">Heading text</div>
  <div class="list-group-item-body">
    <strong>User: </strong><span class="username">@someuser</span>
  </div>
</div>

to:

| title        | username  |
| Heading text | @someuser |

So you would provide an array of container node elements and the mapping of CSS / xpath selector to column title.

$table = $parser->parse(
    $container->findAll('css', '.list-group-item'),
    [
      'title' => ['css', '.list-group-item-heading'],
      'user'  => ['css', '.list-group-item-body .username']
    ]
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions