Problem with DOMXML get_attribute() error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bizt

    Problem with DOMXML get_attribute() error message

    Hi

    Please forgive the length of this post and bear with me. I am having
    trouble between two different servers and the same DOMXML code.

    Basically I am trying to run a script that will:

    1) load an XML file as a variable object ($xml_doc):


    $xml_doc = domxml_open_fil e("menu.xml", DOMXML_LOAD_DON T_KEEP_BLANKS);


    2) locate the first node as a variable object ($node):


    $root = $xml_doc->document_eleme nt ();
    $node = $root->first_child ();


    3) output all node and siblings in sequence:


    while ($node)
    {
    echo "<p>" . $node->get_attribut e ("htext") . "</p>";

    $node->next_sibling ();
    }


    Below is the XML file (very basic):


    <?xml version="1.0" encoding="iso-8859-1"?>
    <menu>
    <opt htext="Home" />
    <opt htext="News" />
    <opt htext="Products &amp; Services" />
    <opt htext="Find us" />
    <opt htext="Faq" />
    <opt htext="Contact us" />
    </menu>


    Now, on my test server it works without any problems and all the nodes
    are output in sequence. However, when I run it on the actual server
    that I will be running the site from, it give me the following results:

    Home

    Fatal error: Call to undefined function: get_attribute() in
    /data/httpd/VirtualHosts/csp/_testing/test_menu07.php on line 51


    Notice how the first node (Home) is output so I can maybe assume the
    following:

    - that $xml_doc and $node are instantiated ok
    - $node is able on the first (while) loop to call the get_attribute
    function so $node as an object has been instatiated correctly
    - It enters the while loop again so $node is present but for some
    reason it doesnt have the get_attribute function.


    Is there anyway that I can get a little more information about $node
    everytime it is put through the while loop again that might tell me why
    it has lost refererence to its functions (in this instance, the
    get_attribute function)?
    I dont have a great deal of knowledge about servers and the IT guys at
    my work dont fully understand the syntax / programming methods of
    DOMXML, is there anything that we can look into (versions,
    configurations etc.) that may be causing this?
    Is there anything that I should be aware about with traversing an XML
    tree in this manner (using the state of $node to control a while loop
    while outputing an attribute)?
    Is there, well, anything other that I could be looking into (problems
    with whitespacing, server configurations etc)?

    I understand that there may be many factors that could be at play but
    if any help would be much appreciated. Thanks

    Burnsy

  • bizt

    #2
    Re: Problem with DOMXML get_attribute() error message

    Sorry, just noticed I'd made a mistake in my post:

    3) output all node and siblings in sequence:

    while ($node)
    {
    echo "<p>" . $node->get_attribut e ("htext") . "</p>";

    $node = $node->next_sibling ();
    }


    This is the code I have been using that doesnt work on the final server
    but does on the test one.

    Comment

    Working...