I currently do alot of data parsing, and have toyed with PHP functions for XML such as simple XML and a few others here and there.
But there always seems to be some sort of issue with dealing with them, mainly due to the way the data is presented.
The most reliable way i have found is to always just simply use preg_match_all and regular expression to pull the my data in to the script for processing.
Does anyone see a problem with this? what are the cons of using Regular expression rather than ready build XML parsers?
My main concern is speed and server utilization of resources.
If you use DOMDocument and DOMXpath, I suspect these will solve your problems.
See https://www.php.net/manual/en/class.domdocument.php and https://www.php.net/manual/en/class.domxpath.php
Could you provide an example of what you are trying to do, though?
Edit
To directly answer your question, though: regular expressions are easy to mess up — especially processing hierarchical structures like xml. Even if you do it right, it will likely be slower than using xpath.
Edit 2
Just to add, php’s implementation of xpath, DOMXpath only supports xpath 1.0. If you need to use regular expressions to evaluate the contents of an element or one of its attributes, then you’d need something supporting xpath 2.0…. or go with a risky, error-prone regex.