call to undefined function:loadXML()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beamor
    New Member
    • Nov 2009
    • 1

    call to undefined function:loadXML()

    Code:
    function art_menu_xml_parcer($content, $showSubMenus)
    {
    $doc = new DOMDocument();
    $doc->loadXML($content);[B]//this is the line in question[/B]
    $parent = $doc->documentElement;
    $elements = $parent->childNodes;
    need help. my site worked fine on my localhost but when i uploaded it to my live server i keep getting this error
    need help to recode line to match my hosting server.
    im using php 5
    i have attached the common_method file
    please help.
    my common_method file is attached.please help

    [code=php]
    <?php

    /* Common Drupal methods definitons using in Artisteer theme export */

    /**
    * Generate the HTML representing a given menu with Artisteer style.
    *
    * @param $mid
    * The block navigation content.
    *
    * @ingroup themeable
    */
    function art_navigation_ links_worker($c ontent = NULL, $showSubMenus) {
    if (!$content) {
    return '';
    }

    $output = art_menu_xml_pa rcer($content, $showSubMenus);

    $menu_str = ' class="menu"';
    if(strpos($cont ent, $menu_str) !== false) {
    $empty_str = '';
    $pattern = '/class="menu"/i';
    $replacement = 'class="art-menu"';
    $output = preg_replace($p attern, $replacement, $output, 1);
    $output = str_replace($me nu_str, $empty_str, $output);
    }

    // used to support Menutrails module
    $output = str_replace("ac tive-trail", "active-trail active", $output);
    return $output;
    }

    function art_menu_xml_pa rcer($content, $showSubMenus)
    {
    $doc = new DOMDocument($co ntent);
    $doc->loadXML();
    $parent = $doc->documentElemen t;
    $elements = $parent->childNodes;

    $nodesToDelete = array();
    foreach ($elements as $element) {
    if (is_a($element, "DOMElement ") && $element->tagName == "li") {
    $children = $element->childNodes;
    foreach ($children as $child) {
    if (is_a($child, "DOMElement ") &&($child->tagName == "a")) {
    $caption = $child->nodeValue;
    $child->nodeValue = "";

    $spanL = $doc->createElement( "span");
    $spanL->setAttribute(" class", "l");
    $spanL->nodeValue = " ";
    $child->appendChild($s panL);

    $spanR = $doc->createElement( "span");
    $spanR->setAttribute(" class", "r");
    $spanR->nodeValue = " ";
    $child->appendChild($s panR);

    $spanT = $doc->createElement( "span");
    $spanT->setAttribute(" class", "t");
    $child->appendChild($s panT);

    $spanT->nodeValue = $caption;
    }
    else if (!$showSubMenus ) {
    $nodesToDelete[] = $child;
    }
    }
    }
    }

    foreach($nodesT oDelete as $node) {
    if ($node != null) {
    $node->parentNode->removeChild($n ode);
    }
    }

    return $doc->saveXML();
    }

    /**
    * Allow themable wrapping of all comments.
    */
    function art_comment_wok er($content, $type = null) {
    static $node_type;
    if (isset($type)) $node_type = $type;
    return '<div id="comments">' . $content . '</div>';
    }

    /*
    * Split out taxonomy terms by vocabulary.
    *
    * @param $node
    * An object providing all relevant information for displaying a node:
    * - $node->nid: The ID of the node.
    * - $node->type: The content type (story, blog, forum...).
    * - $node->title: The title of the node.
    * - $node->created: The creation date, as a UNIX timestamp.
    * - $node->teaser: A shortened version of the node body.
    * - $node->body: The entire node contents.
    * - $node->changed: The last modification date, as a UNIX timestamp.
    * - $node->uid: The ID of the author.
    * - $node->username: The username of the author.
    *
    * @ingroup themeable
    */
    function art_terms_worke r($node) {
    $output = '';
    if (isset($node->links)) {
    $output = '&nbsp;&nbsp;|& nbsp;';
    }
    $terms = $node->taxonomy;

    if ($terms) {
    $links = array();
    ob_start();?><i mg class="art-metadata-icon" src="<?php echo get_full_path_t o_theme(); ?>/images/PostTagIcon.png " width="18" height="18" alt=""/> <?php
    $output .= ob_get_clean();
    $output .= t('Tags: ');
    foreach ($terms as $term) {
    $links[] = l($term->name, taxonomy_term_p ath($term), array('rel' => 'tag', 'title' => strip_tags($ter m->description))) ;
    }
    $output .= implode(', ', $links);
    $output .= ', ';
    }

    $output = substr($output, 0, strlen($output)-2); // removes last comma with space
    return $output;
    }

    /**
    * Return a themed set of links.
    *
    * @param $links
    * A keyed array of links to be themed.
    * @param $attributes
    * A keyed array of attributes
    * @return
    * A string containing an unordered list of links.
    */
    function art_links_woker ($links, $attributes = array('class' => 'links')) {
    $output = '';

    if (count($links) > 0) {
    $output = '';

    $num_links = count($links);
    $index = 0;

    foreach ($links as $key => $link) {
    $class = $key;

    if (strpos ($class, "read_more" ) !== FALSE) {
    break;
    }

    // Automatically add a class to each link and also to each LI
    if (isset($link['attributes']) && isset($link['attributes']['class'])) {
    $link['attributes']['class'] .= ' ' . $key;
    }
    else {
    $link['attributes']['class'] = $key;
    }

    if ($index > 0) {
    $output .= '&nbsp;&nbsp;|& nbsp;';
    }

    // Add first and last classes to the list of links to help out themers.
    $extra_class = '';
    if ($index == 1) {
    $extra_class .= 'first ';
    }
    if ($index == $num_links) {
    $extra_class .= 'last ';
    }

    if ($class) {
    if (strpos ($class, "comment") !== FALSE) {
    ob_start();?><i mg class="art-metadata-icon" src="<?php echo get_full_path_t o_theme(); ?>/images/PostCommentsIco n.png" width="18" height="18" alt=""/> <?php
    $output .= ob_get_clean();
    }
    else {
    ob_start();?><i mg class="art-metadata-icon" src="<?php echo get_full_path_t o_theme(); ?>/images/PostCategoryIco n.png" width="18" height="18" alt=""/> <?php
    $output .= ob_get_clean();
    }
    }

    $index++;
    $output .= get_html_link_o utput($link);
    }
    }

    return $output;
    }

    function get_html_link_o utput($link) {
    $output = '';
    // Is the title HTML?
    $html = isset($link['html']) && $link['html'];

    // Initialize fragment and query variables.
    $link['query'] = isset($link['query']) ? $link['query'] : NULL;
    $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;

    if (isset($link['href'])) {
    if (get_drupal_ver sion() == 5) {
    $output = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
    }
    else {
    $output = l($link['title'], $link['href'], array('language ' => $link['language'], 'attributes'=>$ link['attributes'], 'query'=>$link['query'], 'fragment'=>$li nk['fragment'], 'absolute'=>FAL SE, 'html'=>$html)) ;
    }
    }
    else if ($link['title']) {
    if (!$html) {
    $link['title'] = check_plain($li nk['title']);
    }
    $output = $link['title'];
    }

    return $output;
    }

    /**
    * Format the forum body.
    *
    * @ingroup themeable
    */
    function art_content_rep lace($content) {
    $first_time_str = '<div id="first-time"';
    $article_str = 'class="art-article"';
    $pos = strpos($content , $first_time_str );
    if($pos !== false)
    {
    $output = str_replace($fi rst_time_str, $first_time_str . $article_str, $content);
    $output = <<< EOT
    <div class="art-Post">
    <div class="art-Post-tl"></div>
    <div class="art-Post-tr"></div>
    <div class="art-Post-bl"></div>
    <div class="art-Post-br"></div>
    <div class="art-Post-tc"></div>
    <div class="art-Post-bc"></div>
    <div class="art-Post-cl"></div>
    <div class="art-Post-cr"></div>
    <div class="art-Post-cc"></div>
    <div class="art-Post-body">
    <div class="art-Post-inner">

    <div class="art-PostContent">

    $output

    </div>
    <div class="cleared" ></div>


    </div>

    </div>
    </div>

    EOT;
    }
    else
    {
    $output = $content;
    }
    return $output;
    }

    function art_placeholder s_output($var1, $var2, $var3) {
    $output = '';
    if (!empty($var1) && !empty($var2) && !empty($var3)) {
    $output .= <<< EOT
    <table class="position " width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr valign="top">
    <td width="33%">$va r1</td>
    <td width="33%">$va r2</td>
    <td>$var3</td>
    </tr>
    </table>
    EOT;
    }
    else if (!empty($var1) && !empty($var2)) {
    $output .= <<< EOT
    <table class="position " width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr valign="top">
    <td width="33%">$va r1</td>
    <td>$var2</td>
    </tr>
    </table>
    EOT;
    }
    else if (!empty($var2) && !empty($var3)) {
    $output .= <<< EOT
    <table class="position " width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr valign="top">
    <td width="67%">$va r2</td>
    <td>$var3</td>
    </tr>
    </table>
    EOT;
    }
    else if (!empty($var1) && !empty($var3)) {
    $output .= <<< EOT
    <table class="position " width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr valign="top">
    <td width="50%">$va r1</td>
    <td>$var3</td>
    </tr>
    </table>
    EOT;
    }
    else {
    if (!empty($var1)) {
    $output .= <<< EOT
    <div id="var1">$var1 </div>
    EOT;
    }
    if (!empty($var2)) {
    $output .= <<< EOT
    <div id="var1">$var2 </div>
    EOT;
    }
    if (!empty($var3)) {
    $output .= <<< EOT
    <div id="var1">$var3 </div>
    EOT;
    }
    }

    return $output;
    }

    function artxGetContentC ellStyle($left, $right, $content) {
    if (!empty($left) && !empty($right))
    return 'art-content';
    if (!empty($right) )
    return 'art-content-sidebar1';
    if (!empty($left) > 0)
    return 'art-content-sidebar2';
    return 'content-wide';
    }

    function art_submitted_w orker($submitte d, $date, $name) {
    $output = '';
    ob_start();?><i mg class="art-metadata-icon" src="<?php echo get_full_path_t o_theme(); ?>/images/PostDateIcon.pn g" width="17" height="18" alt=""/> <?php
    $output .= ob_get_clean();
    $output .= $date;
    $output .= '&nbsp;|&nbsp;' ;
    ob_start();?><i mg class="art-metadata-icon" src="<?php echo get_full_path_t o_theme(); ?>/images/PostAuthorIcon. png" width="14" height="14" alt=""/> <?php
    $output .= ob_get_clean();
    $output .= $name;
    return $output;
    }

    function artReadMoreLink ($link) {
    $link['attributes']['class'].=' art-button';
    return '<div class="read_mor e"><p>'.get_htm l_link_output($ link).'</p></div><div class="cleared" ></div>';
    }

    function isArtLinksSet($ links) {
    if (empty($links)) {
    return FALSE;
    }

    $doc = new DOMDocument();
    $doc->loadXML($links );
    $parent = $doc->documentElemen t;
    //check if there's "Read more" in node links only
    if (sizeof($parent->childNodes) == 1) {
    $element = $parent->firstChild;
    $class = $element->getAttribute(" class");
    if (strpos ($class, "read_more" ) !== FALSE) {
    return FALSE;
    }
    }

    return TRUE;
    }
    [/code]
    Last edited by Atli; Nov 21 '09, 11:00 PM. Reason: Added code tags, and moved the code from the attachment into the post.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    I would guess you are getting this error because your server is running PHP4, whereas your localhost is running PHP5. Both versions have a DOMDocument object, but they are not used in the same way.

    Are you 100% sure this is not the case?
    If not, try running the phpinfo() function and checking the version there.

    Comment

    Working...