Dealing with Namespace/Colon in SimpleXML
am 26.10.2007 21:56:03 von Andrew Darby
Hello, all. I'm trying to use SimpleXML to loop through an .xml file,
but when I try to do the following, it chokes on the colon:
foreach ($xml_data->dc:title as $item) {
[do whatever here]
}
The element in the XML has a colon in it, i.e.,
Interesting Book
Anybody know how to deal with this? I must be missing something obvious.
Thanks,
A.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Dealing with Namespace/Colon in SimpleXML
am 30.10.2007 20:08:45 von Neil Smth
At 06:57 28/10/2007, you wrote:
>Message-ID: <68ad571c0710261256k7df9f11bj47ad5e3c72ad5a58@mail.gmail.com>
>From: "Andrew Darby"
>
>Hello, all. I'm trying to use SimpleXML to loop through an .xml file,
>but when I try to do the following, it chokes on the colon:
>
>foreach ($xml_data->dc:title as $item) {
>
>[do whatever here]
>
>}
>
>The element in the XML has a colon in it, i.e.,
>
>Interesting Book
>
>Anybody know how to deal with this? I must be missing something obvious
Yes, but only slightly. The Zend site has a good article on setting
SimpleXML to handle the namespaced nodes :
http://devzone.zend.com/node/view/id/688#Heading3
NB this is really a database mailing list from the point of view of
PHP, you might need to consider an XML list in future ;-)
HTH
Cheers - Neil
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php