Download the PHP package zacksitt/xml-helper without Composer
On this page you can find all versions of the php package zacksitt/xml-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download zacksitt/xml-helper
More information about zacksitt/xml-helper
Files in zacksitt/xml-helper
Download zacksitt/xml-helper
More information about zacksitt/xml-helper
Files in zacksitt/xml-helper
Vendor zacksitt
Package xml-helper
Short Description ???The Laravel XML Helper package simplifies XML data handling within Laravel applications. Easily parse, generate, and transform XML with intuitive methods that integrate seamlessly with Laravel's ecosystem.
License MIT
Package xml-helper
Short Description ???The Laravel XML Helper package simplifies XML data handling within Laravel applications. Easily parse, generate, and transform XML with intuitive methods that integrate seamlessly with Laravel's ecosystem.
License MIT
Please rate this library. Is it a good library?
Informations about the package xml-helper
Laravel XML Helper
The Laravel XML Helper package provides an easy and efficient way to work with XML data in your Laravel applications. It includes methods for converting arrays to XML, parsing XML to arrays, and extracting values using XPath queries.
Installation
To install the package, you can use Composer:
composer require zacksitt/xml-helper
Usage
Converting Arrays to XML
Use the toXML() method to convert a PHP array to an XML string.
use Zacksitt\XmlHelper\XmlHelper;
$array = [
'root' => [
'element' => 'value',
'anotherElement' => 'anotherValue'
]
];
$xmlHelper = new XmlHelper();
$xmlString = $xmlHelper->toXml($array);
echo $xmlString;
Parsing XML to Arrays
The toArray() method parses an XML string into a PHP array.
$xmlString = '<root><element>value</element><anotherElement>anotherValue</anotherElement></root>';
$xmlHelper = new XmlHelper();
$array = xmlHelper->toArray($xmlString);
print_r($array);
Extracting Values with element.
Use the getValue() method to extract values from an XML string using an element name.
$xmlString = '<root><element>value</element><anotherElement>anotherValue</anotherElement></root>';
$xpath = 'anotherElement';
$xmlHelper = new XmlHelper();
$value = $xmlHelper->getValue($xmlString, $xpath);
echo $value; // Output: anotherValue
Methods
toXML(array $data): string
Converts a PHP array to an XML string.
toArray(string $xml): array
Parses an XML string into a PHP array.
getValue(string $xml, string $element): mixed
Extracts a value from an XML string using an XPath query.
License
This package is open-sourced software licensed under the MIT license.
All versions of xml-helper with dependencies
PHP Build Version
Package Version
No informations.
The package zacksitt/xml-helper contains the following files
Loading the files please wait ....