The DOMNamedNodeMap class

(PHP 5, PHP 7)

Class synopsis

DOMNamedNodeMap implements Traversable {
/* Properties */
readonly public int $length ;
/* Methods */
DOMNode getNamedItem ( string $name )
DOMNode getNamedItemNS ( string $namespaceURI , string $localName )
DOMNode item ( int $index )
}

Properties

length

The number of nodes in the map. The range of valid child node indices is 0 to length - 1 inclusive.

Table of Contents

add a note add a note

User Contributed Notes 2 notes

up
4
kendsnyder at gmail dot com
8 years ago
To add to xafford's comment. When iterating a named node map collection using ->item() or using foreach, removing a attribute with DOMNode->removeAttribute() or DOMNode->removeAttributeNode() alters the collection as if it w
  • o il blete,lectionollbelow a nosord'tributthelte with DOs from movi e h D an> 'tributllectifirsiteOnOMNork ie9.cs0 ohe marraylbe remg a attribu with DOs. mote fHP 7).2.9 an Only ExtXP.

    T> hp'>E_r 3> TkeyNor/a>(> 3> T> 3> TkeyNor/a>);
    < 3> T> 3> TkeyNor/a>= > 3> Tspan> ">'<h1d-nav"1DOs="clearfix"1DOs="veAtH </h1veAt'> 3> TkeyNor/a>;
    < 3> T> 3> TkeyNor/a>.= > 3> Tspan> ">'<ptheign="lef="clearfixpDOs="veAtH 3> TkeyNor/a>;

    < 3> T> 3> TkeyNor/a>= new > 3> T> 3> TkeyNor/a>();
    < 3> T> 3> TkeyNor/a>oveAt< 3> T> 3> TkeyNor/a>(> 3> T> 3> TkeyNor/a>);

    < 3> T>/* Method/'tributth with DOs from  ectih1de
    < 3> T> 3> TkeyNor/a>= > 3> T> 3> TkeyNor/a>oveAt< 3> T> TkeyNor/a>(> 3> Tspan> ">'h1'> 3> TkeyNor/a>)oveAt< 3> T> TkeyNor/a>(> 3> T> 3> TkeyNor/a>);
    < 3> T> > 3> TkeyNor/a>= > 3> T> 3> TkeyNor/a>oveAt< 3> T> 3> TkeyNor/a>oveAt< 3> T> ar> TkeyNor/a>;
    re (> 3> T> > 3> TkeyNor/a>= > 3> T> 3> TkeyNor/a>; > 3> T> > 3> TkeyNor/a>< > 3> T> ar> TkeyNor/a>; ++> 3> T> 3> TkeyNor/a>) {
        > 3> T> 3> TkeyNor/a>= > 3> T> 3> TkeyNor/a>oveAt< 3> T> 3> TkeyNor/a>oveAt< 3> T> TkeyNor/a>(> 3> T> 3> TkeyNor/a>)oveAt< 3> T> TkeyNor/a>;
        > 3> T> 3> TkeyNor/a>oveAt< 3> T> TkeyNor/a>(> 3> T> TkeyNor/a>);
        eef= > 3> Tspan> ">x"1:'tributdte with DOM`> 3> T> Tspan> ">`<brveAt"/s3> TkeyNor/a>;
    }
    < 3> T>/* Method/'tributth with DOs from ectipde
    < 3> T> 3> TkeyNor/a>= > 3> T> 3> TkeyNor/a>oveAt< 3> T> TkeyNor/a>(> 3> Tspan> ">'p'> 3> TkeyNor/a>)oveAt< 3> T> TkeyNor/a>(> 3> T> 3> TkeyNor/a>);
    removi (> 3> T> 3> TkeyNor/a>oveAt< 3> T> 3> TkeyNor/a>as > 3> T> 3> TkeyNor/a>=veAt > 3> T> TkeyNor/a>) {
        > 3> T> 3> TkeyNor/a>oveAt< 3> T> TkeyNor/a>(> 3> T> TkeyNor/a>);
        eef= > 3> Tspan> ">xp:'tributdte with DOM`> 3> T> Tspan> ">`<brveAt"/s3> TkeyNor/a>;
    }

    < 3> T> < 3>
    OUTPUT:/br />-------/br />"1:'tributdte with DOM`id`

    Notice: Tryte fto Ite psys in tn-oa>"1:'tributdte with DOM``
    p:'tributdte with DOM`heign`> 3> < /span> /div> <078 class="votes">
    078 chref="/manual/vote-note.php?id=94346&078e=class.domnamednodemap&vote=up" titltle="Vote down!" class="usernotes-voted">down
    4
    kendsnyds commetrong> &p078 cla>
    To add tI stumbn Apup it amp;manMNode->Map::itemk >E ::tributeNode() alter an> 'ectifirsite with DOMNoll beg
    Exaorial(nem>
    T>
    < 3>
    T>/* Method*
    * ocese :
    * <ae="dlickes">h2>('evil')#94346">"https://bugsphp.xaoriasion"xt" hreofolle="qtarg8"> _blank">bugsphp.xaoriasion cla"veAtevil</aveAt
    * spac="dlick should begtributd,ttps: would nem>begDOs=ed.
    */

    < 3> TkeyNor/a> removi ( > 3> T> TkeyNor/a>oveAt< 3> T> 3> TkeyNor/a>as > 3> T> TkeyNor/a>)
    {

        eef= > 3> Tspan> ">'" id=tribu with DO '> 3> TkeyNor/a>, > 3> T> TkeyNor/a>oveAt< 3> T> TkeyNor/a>, > 3> Tspan> ">'<br /veAt'> 3> TkeyNor/a>;

        if ( ! > 3> T> TkeyNor/a>( > 3> T> TkeyNor/a>oveAt< 3> T> TkeyNor/a>, > 3> T> 3> TkeyNor/a>) )
        {
            > 3> T> TkeyNor/a>oveAt< 3> T> TkeyNor/a>( > 3> T> 3> TkeyNor/a>);
        }

    }

    < 3> T> < 3> <
    e ofo>
    " id=tribu with DO ="dlick> 3> < /span> /div> add a note add a note
    iv> id="use>an> d="use>IE]> ontent">
    '>eren'
    'de igle">eren' t id=" siv claaaaaaaaaaaaat id=" siv claaaaaaaaaaas=""> tias antri/Configuan> > ed Interfacs Exaoriad> /liC Encodin Ext> SeeSe>
  • SeR">
  • SeR">
  • >
    My search" Magic /option search"> i/dd>
    Mip'>E> i/dd>
    Privace policy>
    aa
    nspt" src="h:;class="tearch"TopH>< 3>