Namespace prefix isn't defined. How can I define it automatically/ignore error?

Viewed 11239

I made a PHP script which parses XML file and when I try to parse it, an error comes out:

2: DOMDocument::load(): Namespace prefix edf for represent on info is not defined in /users/zzz/testing/meta.xml, line: 2

I've been searching for a fix but I couldn't find any, so I'm posting here. As you can see I'm using DOMDocument class.

My code for parsing XML looks like:

$dom = new DOMDocument();
$metaXML = $dom->load($path."/meta.xml");

The path and all is correct, I'm sure. When I remove the prefix, it works fine. The XML looks like:

<meta>
    <info gamemodes="race" type="map" edf:represent="false"></info>
</meta>

The edf:represent="false" causes an error. I don't want to manually delete edf namespace prefix, because this is not the only XML file I want to parse. There are hundreds of them and the number is rising.

So, my question is, how can I ignore this error (only for XML namespace thing) or how can I define/remove namespace prefix via DOMDocument class?

2 Answers
Related