How to parse XML files with errors using simplexml in PHP?

So I use simplexml with the XML parsing in PHP, but I found that some of the files I needed to parse contains errors. Of course, I could manually edit each and every problematic file, but at about 10000+ files, that would take me forever.Okay, so about the error. When you try to open the XML file in the browser, this message shows up:
kmHn9.png
I found the ff. tag is triggering the error:\[code\]<Public Transport Rules><PublicTransport id="0"><Issued>null</Issued><Files><localfile> <location>Citybus</location> <format>Events</format> </localfile></Files></PublicTransport></Public Transport Rules>\[/code\]The spaces within the tags is causing the issue, apparently. And these tags occur more than once in the file.I think that \[code\]simplexml\[/code\] parses by what it sees in the browser (at face value), so if there is a problem with your XML file, it wont be able to parse normally. I thought of making PHP parse by reading the source file instead, and perhaps editing the file from there. But it seems any \[code\]fopens\[/code\] opens to what you read in the browser page.Been stuck with this problem for a while now. Any advice would be appreciated. Thanks!
 
Back
Top