1

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??? Commented May 5, 2011 at 14:52
  • We cant answer your question without some code. Commented 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. Commented May 5, 2011 at 14:57

1 Answer 1

3

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.

http://blogs.sitepoint.com/simplexml-and-namespaces/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.