Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Xml Iterator

Xml Iterator Laravel Package

halilim/xml-iterator

halilim/xml-iterator offers a simple, memory-efficient way to iterate over XML in PHP. Built on XMLReader, it lets you loop through nodes with foreach and parse large XML files without loading them fully into memory—ideal for big feeds, exports, and streaming XML data.

Deep Wiki
Context7

XML Reader to array/object iterator with low memory usage and an acceptable level of ease of use.

Frequently asked questions about Xml Iterator
How do I install halilim/xml-iterator in a Laravel project?
Run composer require halilim/xml-iterator. It is framework-agnostic, so there is no Laravel service provider, facade, or config file to register. Ensure ext-xmlreader is enabled in every environment, including queue and CI containers, then wrap the iterator behind your own adapter or service class.
Does halilim/xml-iterator support Laravel 11 and Laravel 12?
The library is not coupled to Laravel, so Laravel 11 or 12 does not need a specific integration package. Real compatibility depends on your PHP version and the ext-xmlreader extension rather than the framework major. Verify the package's tested PHP matrix, especially for PHP 8.3 and 8.4, before committing to it.
Will halilim/xml-iterator reduce memory usage when parsing large XML files?
Yes, it is built on XMLReader and yields one matched node at a time, so it does not load the whole document into memory. That makes it suitable for large supplier feeds, sitemaps, exports, and bulk XML APIs. Memory still depends on how much data you retain per node and how you process each yielded item.
How do I handle XML namespaces with halilim/xml-iterator?
Namespace handling is a key thing to verify for your feed format, because a node-name or namespace mismatch can produce zero iterations without an error. Test against real namespaced XML and confirm whether you must select by local name or namespace-aware name. Keep the selection logic in one adapter so a mismatch is easy to fix and test.
Is halilim/xml-iterator safe against XXE and entity expansion attacks?
Do not assume default libxml settings are sufficient; XML is hostile input and XXE or entity-expansion behaviour must be verified explicitly. Confirm how XMLReader options are exposed and whether you can force network access off and external entity substitution disabled. Add tests with malicious XML payloads before processing untrusted feeds.
What happens when the XML is malformed mid-stream with halilim/xml-iterator?
The error contract on malformed XML mid-stream is something to confirm in a spike: it may throw, return false, or stop yielding after partial iteration. Your importer should treat zero nodes and partial results as possible failure modes, not automatic success. Log counts and validate expected nodes before marking an import complete.
How are XML attributes and repeated child elements represented in the array output?
Node-to-array conversion is lossy by design, so attributes, repeated siblings, mixed content, and namespaces may be flattened in ways that differ from SimpleXML assumptions. Test representative files and document how attributes and nested repeated elements appear in your adapter output. Return typed DTOs from your adapter rather than leaking the package's array shape into domain code.
Can halilim/xml-iterator read XML from S3, gzipped files, or php://temp streams?
Support for stream wrappers such as S3, php://temp, and gzipped files should be verified rather than assumed. XMLReader can open URIs in general, but the package's own API may only handle local paths. If you need remote or compressed input, test it early or download and decompress to a local temp file first.
What are alternatives to halilim/xml-iterator for streaming XML in PHP?
Consider prewk/xml-string-streamer, a hand-rolled XMLReader loop, or a SaaS parser if you need different streaming semantics or more control. SimpleXML and DOMDocument are fine for small files but load the document into memory. Keeping the package behind your own FeedReader interface makes swapping implementations low risk.
Is halilim/xml-iterator actively maintained enough for production use?
The project has roughly 19 stars and a single maintainer, with recent release activity but no evident security policy or long-term support commitment. That is workable for a low-level utility if you pin a caret constraint, commit the lock file, and isolate it behind an adapter. Run it against a golden corpus of production files and keep a fallback parser for rollback.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log