Jump to content


Photo

**SOLVED** Extend DOMDocument


  • Please log in to reply
2 replies to this topic

#1 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 20 May 2006 - 08:03 AM

Hey guys, I can't get this to work:

class simpleXML extends DOMDocument
{
    private $filePath;
    
    function __construct($file)
    {
        parent::__construct();
        if(file_exists($file)){
            parent::load($file);
        }
            else {    //Create root element:
            $root = parent::createElement(substr($file,strrpos($file,'/' )+1,strlen($file)));
            parent::appendChild($root);
        }
        $this->filePath = $file;
        $this->preserveWhitespace = false;    
        $this->formatOutput = true;
    }
    function __destruct()
    {
        parent::save($this->filePath);        
    }
}

It just puts the endtag, no starting tag... [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
Maybe DOMDocument just wasn't meant to be extended?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 20 May 2006 - 09:33 AM

Looks fine to me. I get

<?xml version="1.0"?>
<afilename/>

If it were an end tag it would be

</afilename>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 20 May 2006 - 09:45 AM

[!--quoteo(post=375473:date=May 20 2006, 04:33 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ May 20 2006, 04:33 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Looks fine to me. I get

<?xml version="1.0"?>
<afilename/>

If it were an end tag it would be

</afilename>
[/quote]

Whahahaha.... [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] That's so "me"... I could've sworn it said '</file>'!

Thanks! (and I apologize for not paying attention)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users