Sweep: XMLReader support https://github.com/gramps-project/gramps/blob/master/data/grampsxml.dtd format for importing to people objects in eloquent (β Sandbox Passed) #13
This pull request adds support for reading XML files in the grampsxml.dtd format and importing the data into Laravel's Person model using the Eloquent ORM. It includes changes to the XmlReader class in the src/Services/XmlReader.php file.
Summary
Added use LaravelGrampsXml\XmlReader; and use SimpleXMLElement; to the imports.
Added use App\Models\Person; to import the Person model from the Laravel application.
Modified the read method to accept a string parameter for the file path and return an array of Person objects.
Added a check to ensure the file exists before attempting to read it.
Added an error handler to throw an InvalidArgumentException if there are any errors while parsing the XML file.
Implemented the parsing logic using simplexml_load_file and mapped the XML data to Person model attributes.
Added the mapped Person objects to an array and returned it.
Added a finally block to restore the error handler after parsing the XML file.
Fixes #12.
π Latest improvements to Sweep:
New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
PR Feedback (click)
Description
This pull request adds support for reading XML files in the
grampsxml.dtd
format and importing the data into Laravel'sPerson
model using the Eloquent ORM. It includes changes to theXmlReader
class in thesrc/Services/XmlReader.php
file.Summary
use LaravelGrampsXml\XmlReader;
anduse SimpleXMLElement;
to the imports.use App\Models\Person;
to import thePerson
model from the Laravel application.read
method to accept a string parameter for the file path and return an array ofPerson
objects.InvalidArgumentException
if there are any errors while parsing the XML file.simplexml_load_file
and mapped the XML data toPerson
model attributes.Person
objects to an array and returned it.finally
block to restore the error handler after parsing the XML file.Fixes #12.
π Latest improvements to Sweep:
π‘ To get Sweep to edit this pull request, you can: