PHP xpath query on XML with default namespace binding
问题 I have one solution to the subject problem, but it’s a hack and I’m wondering if there’s a better way to do this. Below is a sample XML file and a PHP CLI script that executes an xpath query given as an argument. For this test case, the command line is: ./xpeg "//MainType[@ID=123]" What seems most strange is this line, without which my approach doesn’t work: $result->loadXML($result->saveXML($result)); As far as I know, this simply re-parses the modified XML, and it seems to me that this