Pesho Posted April 26, 2007 Share Posted April 26, 2007 hi all, I have to extract information from a DOM representation. My XML content is: <record> <header> <identifier>oai:ub.rug.nl:dbi/4357aa6e091c0</identifier> <datestamp>2006-07-26T21:01:29Z</datestamp> <setSpec>archive-58</setSpec> </header> <metadata> <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> <dc:title>Just take her seriously</dc:title> <dc:creator>Weijmar Schultz, W.C.M.</dc:creator> <dc:publisher>Rijksuniversiteit Groningen</dc:publisher> <dc:date>2005-01-01</dc:date> <dc:type>Inaugural lecture</dc:type> <dc:format>text/html</dc:format> <dc:format>application/pdf</dc:format> <dc:identifier>http://irs.ub.rug.nl/ppn/271588403</dc:identifier> <dc:language>nl_NL</dc:language> <dc:relation>http://www.rug.nl/</dc:relation> <dc:rights>Rijksuniversiteit Groningen</dc:rights> </oai_dc:dc> </metadata> </record> first I try to extract information about the <metadata> tag: $records = $dom->documentElement->getElementsByTagName('dc:creator'); foreach($records as $record) { $children = $record->childNodes; foreach($children as $child) { echo $child->nodeName; } } It works fine and the output is: #textoai_dc:dc#text However, when I try the same code for the <dc:creator> tag, the otput is empty! I also tried: $records = $dom->documentElement->getElementsByTagName('dc:creator'); foreach($records as $record) { echo $record->nodeName; } ...and the output was emtpy again ! ? ! ? I'm totally confused why it doesn't return any information about the <dc:creator> tag. Thanks in advance Pesho Link to comment https://forums.phpfreaks.com/topic/48746-solved-php-dom-problem/ Share on other sites More sharing options...
Pesho Posted April 26, 2007 Author Share Posted April 26, 2007 I just saw I've got a typing mistake in the second code box. It should be 'metadata' instead of 'dc:creator' sorry for that Link to comment https://forums.phpfreaks.com/topic/48746-solved-php-dom-problem/#findComment-238918 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.