load( 'blogroll.xml' ); /* $docElem = $doc->documentElement(); */ $mtInfo = $doc->getElementsByTagName( 'formatting' )->item( 0 ); # blockType: this should be widget or module $blockType = $mtInfo->getElementsByTagName( 'blockType' )->item( 0 )->nodeValue; # headerType: this should be an HTML header widget, like h2 or h3 $headerType = $mtInfo->getElementsByTagName( 'headerType' )->item( 0 )->nodeValue; # listType: this is usually module-list, if blockType is module $listType = $mtInfo->getElementsByTagName( 'listType' )->item( 0 )->nodeValue; $listItemString = ($listType.length > 0) ? '
  • ' : '
  • '; $categories = $doc->getElementsByTagName( 'category' ); foreach( $categories as $cat ) { $links = $cat->getElementsByTagName( 'link' ); if( $links->length > 0 ) { $catName = $cat->getElementsByTagName( 'title' )->item( 0 )->nodeValue; $output = '
    \n<" . $headerType . ' class="'.$blockType.'-header">'; $output .= "$catName\n"; $output .= '
    ' . "\n"; $output .= ($listType.length > 0) ? "
      \n" : "
        \n"; } foreach( $links as $link ) { $linkURL = $link->getElementsByTagName( 'url' )->item( 0 )->nodeValue; $linkName = $link->getElementsByTagName( 'name' )->item( 0 )->nodeValue; $linkComment = $link->getElementsByTagName( 'comment' )->item( 0 )->nodeValue; $output .= $listItemString.''.$linkName.' '.$linkComment."\n"; } $output .= "
      \n
    \n
    "; print $output; } ?>