Jump to content

janxyzphp

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

janxyzphp's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. eh, not sure, i thought it was more about trying to import and/or overwrite the properties of the instance. with the Magic _get, _set and _call XxDomDocument allows me transparent access to all properties and methods of the encapsulated DomDocument instance. usage like so: $doc = new XxDomDocument(); $doc->validatedOnParse = true; $doc-Load('page.html'); $node = $doc->getElementById('myid'); $docElement = $doc->documentElement; (of course u'd have to modify the doctype settings in the previous code snippet to ur liking) But perhaps i misread the thread and my suggestion is redundant. Jan
  2. Yep, that did not work for me either. So i declared a new class XxDomDocument and encapsulated the DomImplementation and DomDocument in the constructor. (U can add params to the constructor if u want and pass to the DomImplementation u are creating). The resulting object, this->doc, i then 'decorate' with the php5 magic functions _set, _get and _call. The resulting XxDomDocument for all intends and purposes is the same as a DomDucement created by the DomImplementation. Now u can add in or extend the XxDomDocument class with whatever methods u desire. is looks a bit like so: [code] class XxDomDocument { protected $doc; public function __construct () { $DOM = new DOMImplementation(); $dtd = $DOM->createDocumentType ("html" , "-//W3C//DTD XHTML 1.0 Strict//EN" , "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); $this->doc = $DOM->createDocument ( null, null, $dtd); $this->doc->formatOutput = true; $this->doc->preserveWhiteSpace = false; } public function __set( $name, $value ) { if( property_exists( $this->doc, $name ) ) $this->doc->$name = $value; } public function __get( $name ) { if( property_exists( $this->doc, $name ) ) return $this->doc->$name; } public function __call( $name, $params ) { if( method_exists( $this->doc, $name ) ) return call_user_func_array( array( $this->doc, $name ), $params ); } // end } [/code] I can validate and use getElementById. I can add for example a method to print a page without the xml declaration which would throw WINIE6 into quirksmode... J
  3. Also want to extend the DomDocument.... Could a Decorator class help here? Anyone tried this? J
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.