11
11
tabular data represented as HTML Table. Once installed you will be able to do the following:
12
12
13
13
``` php
14
- use Bakame\TabularData\ HtmlTable\Parser;
14
+ use Bakame\HtmlTable\Parser;
15
15
16
16
$table = Parser::new()
17
17
->tableHeader(['rank', 'move', 'team', 'player', 'won', 'drawn', 'lost', 'for', 'against', 'gd', 'points'])
@@ -57,7 +57,7 @@ for more information.
57
57
** The ` Parser ` constructor is private to instantiate the object you are required to use the ` new ` method instead**
58
58
59
59
``` php
60
- use Bakame\TabularData\ HtmlTable\Parser;
60
+ use Bakame\HtmlTable\Parser;
61
61
62
62
$parser = Parser::new()
63
63
->ignoreTableHeader()
@@ -72,7 +72,7 @@ To extract and parse your table use either the `parseHtml` or `parseFile` method
72
72
If parsing is not possible a ` ParseError ` exception will be thrown.
73
73
74
74
``` php
75
- use Bakame\TabularData\ HtmlTable\Parser;
75
+ use Bakame\HtmlTable\Parser;
76
76
77
77
$parser = Parser::new();
78
78
@@ -97,7 +97,7 @@ Both methods return a `Table` instance which implements the `League\Csv\TabularD
97
97
interface and also give access to the table caption if present via the ` getCaption ` method.
98
98
99
99
``` php
100
- use Bakame\TabularData\ HtmlTable\Parser;
100
+ use Bakame\HtmlTable\Parser;
101
101
102
102
$html = <<<HTML
103
103
<div >
@@ -161,7 +161,7 @@ favor `Parser::tableXpathPosition` which expects an `xpath` expression.
161
161
If the expression is valid, and a list of table is found, the first result will be returned.
162
162
163
163
``` php
164
- use Bakame\TabularData\ HtmlTable\Parser;
164
+ use Bakame\HtmlTable\Parser;
165
165
166
166
$parser = Parser::new()->tablePosition('table-id'); // parses the <table id =' table-id' >
167
167
$parser = Parser::new()->tablePosition(3); // parses the 4th table of the page
@@ -177,7 +177,7 @@ recommended to use one or the other but not both at the same time.**
177
177
You can optionally define a caption for your table if none is present or found during parsing.
178
178
179
179
``` php
180
- use Bakame\TabularData\ HtmlTable\Parser;
180
+ use Bakame\HtmlTable\Parser;
181
181
182
182
$parser = Parser::new()->tableCaption('this is a generated caption');
183
183
$parser = Parser::new()->tableCaption(null); // remove any default caption set
@@ -194,18 +194,18 @@ But you can override this behaviour using one of these settings:
194
194
Tells where to locate and resolve the table header
195
195
196
196
``` php
197
- use Bakame\TabularData\ HtmlTable\Parser;
198
- use Bakame\TabularData\ HtmlTable\Section;
197
+ use Bakame\HtmlTable\Parser;
198
+ use Bakame\HtmlTable\Section;
199
199
200
200
$parser = Parser::new()->tableHeaderPosition(Section::Thead, 3);
201
201
// header is the 4th row in the <thead > table section
202
202
```
203
203
204
- The method uses the ` Bakame\TabularData\ HtmlTable\Section ` enum to designate which table section to use
204
+ The method uses the ` Bakame\HtmlTable\Section ` enum to designate which table section to use
205
205
to resolve the header
206
206
207
207
``` php
208
- use Bakame\TabularData\ HtmlTable\Section;
208
+ use Bakame\HtmlTable\Section;
209
209
210
210
enum Section
211
211
{
@@ -225,7 +225,7 @@ Instructs the parser to resolve or not the table header using `tableHeaderPositi
225
225
If no resolution is done, no header will be included in the returned ` Table ` instance.
226
226
227
227
``` php
228
- use Bakame\TabularData\ HtmlTable\Parser;
228
+ use Bakame\HtmlTable\Parser;
229
229
230
230
$parser = Parser::new()->ignoreTableHeader(); // no table header will be resolved
231
231
$parser = Parser::new()->resolveTableHeader(); // will attempt to resolve the table header
@@ -237,8 +237,8 @@ You can specify directly the header of your table and override any other table h
237
237
related configuration with this configuration
238
238
239
239
``` php
240
- use Bakame\TabularData\ HtmlTable\Parser;
241
- use Bakame\TabularData\ HtmlTable\Section;
240
+ use Bakame\HtmlTable\Parser;
241
+ use Bakame\HtmlTable\Section;
242
242
243
243
$parser = Parser::new()->tableHeader(['rank', 'team', 'winner']);
244
244
```
@@ -251,8 +251,8 @@ You can skip or re-arrange the source columns by skipping them by their offsets
251
251
re-ordering the offsets.
252
252
253
253
``` php
254
- use Bakame\TabularData\ HtmlTable\Parser;
255
- use Bakame\TabularData\ HtmlTable\Section;
254
+ use Bakame\HtmlTable\Parser;
255
+ use Bakame\HtmlTable\Section;
256
256
257
257
$parser = Parser::new()->tableHeader([3 => 'rank', 7 => 'winner', 5 => 'team']);
258
258
// only 3 column will be extracted the 4th, 6th and 8th columns
@@ -265,8 +265,8 @@ $parser = Parser::new()->tableHeader([3 => 'rank', 7 => 'winner', 5 => 'team'])
265
265
Tells which section should be parsed based on the ` Section ` enum
266
266
267
267
``` php
268
- use Bakame\TabularData\ HtmlTable\Parser;
269
- use Bakame\TabularData\ HtmlTable\Section;
268
+ use Bakame\HtmlTable\Parser;
269
+ use Bakame\HtmlTable\Section;
270
270
271
271
$parser = Parser::new()->includeSection(Section::Tbody); // thead and tfoot are included during parsing
272
272
$parser = Parser::new()->excludeSection(Section::Tr, Section::Tfoot); // table direct tr children and tfoot are not included during parsing
@@ -292,7 +292,7 @@ Adds or remove a record formatter applied to the data extracted from the table b
292
292
can access it. The header is not affected by the formatter if it is defined.
293
293
294
294
``` php
295
- use Bakame\TabularData\ HtmlTable\Parser;
295
+ use Bakame\HtmlTable\Parser;
296
296
297
297
$parser = Parser::new()->withFormatter($formatter); // attach a formatter to the parser
298
298
$parser = Parser::new()->withoutFormatter(); // removed the attached formatter if it exists
@@ -331,7 +331,7 @@ $formatter = function (array $record): array {
331
331
Tells whether the parser should ignore or throw in case of malformed HTML content.
332
332
333
333
``` php
334
- use Bakame\TabularData\ HtmlTable\Parser;
334
+ use Bakame\HtmlTable\Parser;
335
335
336
336
$parser = Parser::new()->ignoreXmlErrors(); // ignore the XML errors
337
337
$parser = Parser::new()->failOnXmlErrors(3); // throw on XML errors
0 commit comments