I know the difference between xmlreader and other tree based parsers like simplexml and dom. But what is the difference between xmlreader and xmlparser? Is there any benefit in using one over another?
I need to parse relatively big xml files, affiliate datafeeds about 100M.
They utilize two different software architectures - push vs pull.
XMLReader is a "pull parser". You are responsible for creating a big loop and calling the read() function to move the cursor forward. This software architecture tends to be easier to understand intuitively.
XMLParser is an event-based "push parser". You are responsible for registering callback functions that are triggered by events such as start_element, end_element, character_data, start_namespace_decl, etc. When you call xml_parse(), the Expat library will process the entire XML document using your callback functions.
If you don't understand the subtleties between push vs pull architecture, then I recommend that you start with XMLReader because "pull" is simpler to understand and easier to visualize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With