WordPress.org

Support

Support » Themes and Templates » WordPress and SimpleXML

WordPress and SimpleXML

  • I’m trying to setup a simple method of storing and retriving variables using SimpleXML.

    It looks something like this:

    The Code[options.php]:

    $options = array(
    ‘style’ = simplexml_load_file(‘style.xml’),
    ‘class’ = simplexml_load_file(‘class.xml’),


    );

    The XML[class.xml]:

    <?xml version=’1.0′ encoding=’UTF-8′?>
    <class>
    <alignment_recentposts>leftalign</alignment_recentposts>
    <alignment_postbycategory>rightalign</alignment_postbycategory>


    </class>

    And the is loaded like this:

    <div class=”recent <?php echo $options[‘class’]->alignment_recentposts; ?>”>


    </div>

    Outside or wordpress this works fine, inside it fails. I don’t have access to the php server settings, so I can’t turn on error logging or see any sort of errors. It just goes blank at the point of the error, making debugging very difficult. I’ve downloaded software to help with the debugging, but I don’t particularly want to install a full test server and database to support wordpress for debugging, so I just stick to simple troubleshooting with this software.

    I’ve tried include(‘options.php’) in the header, in the body, i’ve changed the varable name from $options to $vars to $poopie, and I still get the same results, so its not a conflict. Once I comment out the ‘simplexml_load_file’ function it works. I haven’t tested to see if I can set any variable to an object in the same location in the code, but I just want to see if there is any solutions. Thanks.

  • The topic ‘WordPress and SimpleXML’ is closed to new replies.
Skip to toolbar