Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
push:
branches:
- main # Or the branch you use for documentation
pull_request:
paths:
- "docs/**" # Only trigger if there are changes in the documentation folder

jobs:
build-docs:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Simple, fast, and extension-free parser for eXeLearning project files
- Extract text content from XML
- Detect file version
- Extract entire .elp file contents
- Retrieve full metadata tree
- No external extensions required
- Lightweight and easy to use (less than 4 KB footprint library)
- Compatible with PHP 8.0 to PHP 8.5
Expand Down Expand Up @@ -98,6 +99,12 @@ $data = $parser->toArray();

// JSON serialization
$jsonData = json_encode($parser);

// Export directly to a JSON file
$parser->exportJson('path/to/output.json');

// Retrieve full metadata as array
$meta = $parser->getMetadata();
```

## Error Handling
Expand Down
17 changes: 17 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ JSON serialization method implementing JsonSerializable interface.

- **Returns:** mixed - Data to be JSON serialized

#### `exportJson(?string $destinationPath = null): string`

Export parsed data to JSON. If a destination path is provided, the JSON will be written to that file.

- **Parameters:**
- `$destinationPath` (string|null): Optional file path for the JSON output
- **Throws:** `Exception` if the JSON cannot be written
- **Returns:** string - JSON representation of the parsed data

#### `getMetadata(): array`

Return a detailed metadata array containing Package, Dublin Core, LOM and LOM-ES
information together with the page tree.

- **Throws:** `Exception` if the XML cannot be parsed
- **Returns:** array - Metadata and content structure

#### `extract(string $destinationPath): void`

Extract contents of an ELP file to a specified directory.
Expand Down
12 changes: 12 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ELP Parser is a PHP library designed to parse and extract content from ELP (eXe

- Parse ELP files (both version 2 and 3 supported)
- Extract metadata like title, description, author, etc.
- Retrieve a complete metadata tree
- Access learning resource information
- Extract package contents to a specified directory
- JSON serialization support
Expand Down Expand Up @@ -133,6 +134,17 @@ $data = $parser->toArray();
$json = json_encode($parser);
```

#### Exporting to a JSON file

You can directly export the parsed data to a JSON file using `exportJson()`:

```php
$parser->exportJson('path/to/output.json');

// Obtain a metadata tree
$meta = $parser->getMetadata();
```

### Version Compatibility

The library supports both version 2 and version 3 of ELP files. The parsing process automatically detects the version and handles the content appropriately.
Expand Down
Loading