get XML Namespace Elements using PHP SimpleXML
PHP has a great SimpleXML library that converts XML to an object that can be processed with normal property selectors and array iterators. I’ve been using this quite a bit lately to process some XML documents. The library documentation isn’t that great when it comes to processing Namespace Elements within your XML document. An example of such use case is when you are parsing an RSS feed that has XML Namespace elements . Consider the following example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <?xml version = "1.0" encoding = "UTF-8" ?> <rss version = "2.0" xmlns:opensearch = "http://a9.com/-/spec/opensearch/1.1/" xmlns:dc = "http://purl.org/dc/elements/1.1/" > <channel > .... <item > <title > My Title </title > <description > My Item </description > <dc:publisher > ABC </dc:publisher > <dc:creator > DEF </dc:creator > <dc:date ...