<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >DOMNode->replaceChild()</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="DOM Functions" HREF="ref.dom.html"><LINK REL="PREVIOUS" TITLE="DOMNode->removeChild()" HREF="function.dom-domnode-removechild.html"><LINK REL="NEXT" TITLE="DOMNodelist->item()" HREF="function.dom-domnodelist-item.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.dom-domnode-removechild.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.dom-domnodelist-item.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.dom-domnode-replacechild" ></A >DOMNode->replaceChild()</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN42332" ></A ><P > (no version information, might be only in CVS)</P >DOMNode->replaceChild() -- Replaces a child </DIV ><DIV CLASS="refsect1" ><A NAME="AEN42335" ></A ><H2 >说明</H2 >class <B CLASS="classname" >DOMNode</B > { <BR ></BR >DOMNode <B CLASS="methodname" >replaceChild</B > ( DOMNode newnode, DOMNode oldnode )<BR ></BR >}<P > This function replaces the child <CODE CLASS="parameter" >oldnode</CODE > with the passed new node. If the new node is already a child it will not be added a second time. If the replacement succeeds the old node is returned. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN42351" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >newnode</CODE ></DT ><DD ><P > The new node. It must be a member of the target document, i.e. created by one of the DOMDocument->createXXX() methods or imported in the document by <A HREF="function.dom-domdocument-importnode.html" >DOMDocument->importNode()</A >. </P ></DD ><DT ><CODE CLASS="parameter" >oldnode</CODE ></DT ><DD ><P > The old node. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN42366" ></A ><H2 >返回值</H2 ><P > The old node or <TT CLASS="constant" ><B >FALSE</B ></TT > if an error occur. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN42370" ></A ><H2 >错误/异常</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >DOM_NO_MODIFICATION_ALLOWED_ERR</B ></TT ></DT ><DD ><P > Raised if this node is readonly or if the previous parent of the node being inserted is readonly. </P ></DD ><DT ><TT CLASS="constant" ><B >DOM_HIERARCHY_REQUEST_ERR</B ></TT ></DT ><DD ><P > Raised if this node is of a type that does not allow children of the type of the <CODE CLASS="parameter" >newnode</CODE > node, or if the node to put in is one of this node's ancestors or this node itself. </P ></DD ><DT ><TT CLASS="constant" ><B >DOM_WRONG_DOCUMENT_ERR</B ></TT ></DT ><DD ><P > Raised if <CODE CLASS="parameter" >newnode</CODE > was created from a different document than the one that created this node. </P ></DD ><DT ><TT CLASS="constant" ><B >DOM_NOT_FOUND</B ></TT ></DT ><DD ><P > Raised if <CODE CLASS="parameter" >oldnode</CODE > is not a child of this node. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN42397" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.dom-domnode-appendchild.html" >DOMNode->appendChild()</A ></TD ></TR ><TR ><TD ><A HREF="function.dom-domnode-removechild.html" >DOMNode->removeChild()</A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.dom-domnode-removechild.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.dom-domnodelist-item.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >DOMNode->removeChild()</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.dom.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >DOMNodelist->item()</TD ></TR ></TABLE ></DIV ></BODY ></HTML >