Jump to content

[SOLVED] PHP dom problem...


Pesho

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.