Re: Re: SimpleXML or DOMDocument help

From: Date: Thu, 10 Dec 2009 00:46:58 +0000
Subject: Re: Re: SimpleXML or DOMDocument help
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-300353@lists.php.net to get a copy of this message
Shawn McKenzie wrote:
Michael Alaimo wrote:
Hello All, I have an XML document that has elements as such:
        <Query:Expression>
          <Query:ResourceID>
            <Query:Equal>Test/Query:Equal>
          </Query:ResourceID>
        </Query:Expression>
I cannot figure out how to access these with simple xml. I am not opposed to a DOMDocument solution either. Would anyone know what to do in this case? I think the problem is the :. Regards, Mike
What's the entire XML document? You need a xmlns declaration as Query is a namespace.
I have run into documents that use a namespace without properly defining it. Seems fairly common in data sets from academic sources (IE vertebrate museum records). Usually there is only one namespace, and you can use a regular expression to just remove it before importing the document. IE - $buffer = preg_replace('/Query:/','',$input); then import the $buffer

« previous php.general (#300353) next »