PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > DOMElement doesn't seem to extend DOMNode...?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
DOMElement doesn't seem to extend DOMNode...?

Réponse
 
LinkBack Outils de la discussion
Vieux 13/11/2007, 04h25   #1
Sean Quinn
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut DOMElement doesn't seem to extend DOMNode...?

I realize what the documentation says, but when creating both a new
DOMElement object, or extending the DOMElement object I don't have
access to any DOMNode methods in PHP 5.2.0.
e.g.

class HtmlElement extends DOMElement
{
...
}

$htmlElement = new HtmlElement();
$htmlElement->appendChild(...);

Will not work because the method is supposedly undefined. In
addition:

$domEl = new DOMElement();
$domEl->appendChild(...);

.... doesn't seem to work either. I've looked through several sources
online and offline which all seem to indicate that calls to DOMNode
methods should be working, but they aren't for me. Am I going crazy?
Am I doing something wrong? Anyone please ! Thanks!

  Réponse avec citation
Vieux 13/11/2007, 07h16   #2
taps128
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOMElement doesn't seem to extend DOMNode...?

Sean Quinn wrote:
> I realize what the documentation says, but when creating both a new
> DOMElement object, or extending the DOMElement object I don't have
> access to any DOMNode methods in PHP 5.2.0.
> e.g.
>
> class HtmlElement extends DOMElement
> {
> ...
> }
>
> $htmlElement = new HtmlElement();
> $htmlElement->appendChild(...);
>
> Will not work because the method is supposedly undefined. In
> addition:
>
> $domEl = new DOMElement();
> $domEl->appendChild(...);
>
> ... doesn't seem to work either. I've looked through several sources
> online and offline which all seem to indicate that calls to DOMNode
> methods should be working, but they aren't for me. Am I going crazy?
> Am I doing something wrong? Anyone please ! Thanks!
>

You can't append an child to an initialized DOMElement until it's
appended to the DOMDocument.
$dom=new DOMDocument();
$ele=new DOMElement('p');
$dom->appendChild($ele);
$ele2=new DOMELement('br');
$ele->appendChild($ele2);
  Réponse avec citation
Vieux 13/11/2007, 14h35   #3
Sean Quinn
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: DOMElement doesn't seem to extend DOMNode...?

On Nov 13, 1:16 am, taps128 <nstje...@gmail.com> wrote:
> Sean Quinn wrote:
> > I realize what the documentation says, but when creating both a new
> > DOMElement object, or extending the DOMElement object I don't have
> > access to any DOMNode methods in PHP 5.2.0.
> > e.g.

>
> > class HtmlElement extends DOMElement
> > {
> > ...
> > }

>
> > $htmlElement = new HtmlElement();
> > $htmlElement->appendChild(...);

>
> > Will not work because the method is supposedly undefined. In
> > addition:

>
> > $domEl = new DOMElement();
> > $domEl->appendChild(...);

>
> > ... doesn't seem to work either. I've looked through several sources
> > online and offline which all seem to indicate that calls to DOMNode
> > methods should be working, but they aren't for me. Am I going crazy?
> > Am I doing something wrong? Anyone please ! Thanks!

>
> You can't append an child to an initialized DOMElement until it's
> appended to the DOMDocument.
> $dom=new DOMDocument();
> $ele=new DOMElement('p');
> $dom->appendChild($ele);
> $ele2=new DOMELement('br');
> $ele->appendChild($ele2);


How does that functionality even work though--it doesn't seem to make
sense from a structure point of view. I understand that upon appending
an element to a DOMDocument it probably initializes certain properties
within the DOMElement, but shouldn't I still be able to see those
properties and/or methods as available before I even append it to a
DOMDocument? I'm not even able to see the method appendChild() under
DOMElement (at least before appending the DOMElement to a DOMDocument,
which I have yet to experiment with).

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h06.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08733 seconds with 11 queries