Welcome to the documentation for the Feedparser framework!
Introduction
Feedparser is a powerful and easy-to-use library for parsing and working with RSS and Atom feeds. Whether you need to read feed data, extract specific information, or manipulate the feed content, Feedparser has got you covered.
Installation
Prerequisites
- PHP version 7.0 or higher
- Composer package manager
Installation via Composer
To install Feedparser using Composer, execute the following command in your project directory:
composer require feedparser
Getting Started
Parsing a Feed
To parse an RSS or Atom feed, you need to provide the URL or the XML content to the Feedparser\Parser
class:
// Parse a feed using a URL $parser = new Feedparser\Parser(); $feed = $parser->parse('https://example.com/feed.xml'); // Parse a feed using XML content $xmlContent = file_get_contents('path/to/feed.xml'); $feed = $parser->parse($xmlContent);
Retrieve Feed Information
Once the feed is parsed, you can access various properties and methods to retrieve information:
// Retrieve feed properties $title = $feed->getTitle(); $description = $feed->getDescription(); $link = $feed->getLink(); // Print feed information echo "Title: " . $title; echo "Description: " . $description; echo "Link: " . $link; // Get all items in the feed $items = $feed->getItems(); // Loop through each item and retrieve details foreach ($items as $item) { $itemTitle = $item->getTitle(); $itemPublishedDate = $item->getPublishedDate(); $itemLink = $item->getLink(); echo "Item Title: " . $itemTitle; echo "Published Date: " . $itemPublishedDate; echo "Link: " . $itemLink; }
Features
Feed Information
- Retrieve feed properties such as title, description, and link
- Access feed items and their details
- Detect feed type (RSS or Atom)
Feed Manipulation
- Add new items to a feed
- Remove existing items from a feed
- Edit properties of feed items
Data Validation
Feedparser offers built-in validation methods to ensure the integrity of the feed content:
// Validate feed format $isValidFormat = $parser->validateFormat('https://example.com/feed.xml'); if ($isValidFormat) { echo "The feed is in a valid format."; } else { echo "Invalid feed format."; } // Validate feed content $isValidContent = $parser->validateContent('https://example.com/feed.xml'); if ($isValidContent) { echo "The feed content is valid."; } else { echo "Invalid feed content."; }
Contributing
We welcome contributions from the community! If you encounter any bugs or have ideas for new features, please check out our GitHub repository and open an issue or submit a pull request.
https://github.com/feedparser
Support
If you need any assistance or have questions, feel free to reach out to our support team:
- Email: support@feedparser.com
- Forum: https://forum.feedparser.com
License
Feedparser is released under the MIT License. You can find the detailed license information in the LICENSE
file of the GitHub repository.