I'm trying to get an xml stream by using curl. I've recieved the string with curl but I'm having troubles parsing the xmlstream with SimpleXML. The url im using is http://www.google.com/books/feeds/volumes/fR4vqfywNlgC and it seems to be ignoring the parts containing "dc". Why?
3
-
I cannot see any XML at that URL. And could You please provide some code???shadyyx– shadyyx2011-05-05 14:52:45 +00:00Commented May 5, 2011 at 14:52
-
We cant answer your question without some code.GZaidman– GZaidman2011-05-05 14:54:46 +00:00Commented May 5, 2011 at 14:54
-
In case you were unsure: curl will not process your XML. If the download is fine, curl is irrelevant here.Álvaro González– Álvaro González2011-05-05 14:57:01 +00:00Commented May 5, 2011 at 14:57
Add a comment
|
1 Answer
The dublin core data (at least, I'm assuming that's what the DC prefix means in this case) uses its own namespace. You need to refer to that namespace when retrieving these elements. This can be done using the 'children' method.
Example:
$sxml = simplexml_load_string($xml);
$dcData = $sxml->children('dc', TRUE);
echo (string)$dcData->creator;
An article/posting detailing the problem and solution can be found here.