Give this a try https://github.com/nathanmac/laravel-parser
XML Parsing
Is there a package I could use with Laravel 5 that lets me parse an XML easily? Other formats are also a plus but not necessary.
@RachidLaasri it's for Laravel 4.
@toniperic copy the relevant code from the package https://github.com/nathanmac/laravel-parser/blob/master/src/Nathanmac/Parser/Parser.php#L33-L41
@toniperic Did you find a solution for this?
Thanks!
I am fairly new to Laravel. Will this work for 5? If so, does it require pulling in the relevant code to a help macro or something?
I guess more importantly, will this allow me to go JSON array -> XML.
Did you ever find one that allowed for JSON (Array) -> XML?
I am using XMLWriter with great success. http://php.net/manual/en/book.xmlwriter.php
I am using json_decode on my array prior to applying XMLWriter.
If you have a string containing XML and you want to convert it into an associative array:
// Load the XML
$xmlResponse = simplexml_load_string($response->getBody());
// JSON encode the XML, and then JSON decode to an array.
$responseArray = json_decode(json_encode($xmlResponse), true);
When working with large datasets, this approach might not be the best since you're loading the entire dataset into memory. Check XMLReader, perhaps?
https://github.com/Rodenastyle/stream-parser looks like very interesting multi-format parser.
I recently released a package to make xml to array transformations pretty painless: https://github.com/mtownsend5512/xml-to-array
@BLOOMANITY - Thank you!
Please or to participate in this conversation.