Why use an XML parser?

nyotorres

New Member
I'm a somewhat experienced PHP scripter, however I just dove into parsing XML and all that good stuff.I just can't seem to wrap my head around why one would use a separate XML parser instead of just using the \[code\]explode\[/code\] function, which seems to be just as simple. Here's what I've been doing (assuming there is a valid XML file at the path \[code\]xml.php\[/code\]):\[code\]$contents = file_get_contents("xml.php");$array1 = explode("<a_tag>", $contents);$array2 = explode("</a_tag>", $array1[1]);$data = http://stackoverflow.com/questions/3597239/$array2[0];\[/code\]So my question is, what is the practical use for an XML parser if you can just separate the values into arrays and extract the data from that point?Thanks in advance! :)
 
Back
Top