Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 6135

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>DomNode-&#62;insert_before</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="DOM XML Functions"
HREF="ref.domxml.html"><LINK
REL="PREVIOUS"
TITLE="DomNode->has_child_nodes"
HREF="function.domnode-has-child-nodes.html"><LINK
REL="NEXT"
TITLE="DomNode->is_blank_node"
HREF="function.domnode-is-blank-node.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"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.domnode-has-child-nodes.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.domnode-is-blank-node.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.domnode-insert-before"
></A
>DomNode-&#62;insert_before</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN41593"
></A
><P
>    (no version information, might be only in CVS)</P
>DomNode-&#62;insert_before&nbsp;--&nbsp;
   Inserts new node as child
  </DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN41596"
></A
><H2
>Descrição</H2
>domelement <B
CLASS="methodname"
>DomNode-&#62;insert_before</B
> ( domelement newnode, domelement refnode )<BR
></BR
><P
>&#13;   This function inserts the new node <CODE
CLASS="parameter"
>newnode</CODE
> right
   before the node <CODE
CLASS="parameter"
>refnode</CODE
>. The return value is the 
   inserted node. If you plan to do further modifications on the appended 
   child you must use the returned node.
  </P
><P
>&#13;   (PHP &#62;= 4.3 only) If <CODE
CLASS="parameter"
>newnode</CODE
> already is part of a 
   document, it will be first unlinked from its existing context. If 
   <CODE
CLASS="parameter"
>refnode</CODE
> is NULL, then <CODE
CLASS="parameter"
>newnode</CODE
>
   will be inserted at the end of the list of children.  
  </P
><P
>&#13;   <A
HREF="function.domnode-insert-before.html"
><B
CLASS="function"
>domnode_insert_before()</B
></A
> is very similar to
   <A
HREF="function.domnode-append-child.html"
><B
CLASS="function"
>domnode_append_child()</B
></A
> as the following example shows
   which does the same as the example at
   <A
HREF="function.domnode-append-child.html"
><B
CLASS="function"
>domnode_append_child()</B
></A
>.
  </P
><P
>&#13;   <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN41619"
></A
><P
><B
>Exemplo 1. Adding a child</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#007700">include(</font><font color="#DD0000">"example.inc"</font><font color="#007700">);<br /><br />if (!</font><font color="#0000BB">$dom </font><font color="#007700">= </font><font color="#0000BB">domxml_open_mem</font><font color="#007700">(</font><font color="#0000BB">$xmlstr</font><font color="#007700">)) {<br />&nbsp;&nbsp;echo </font><font color="#DD0000">"Error while parsing the document\n"</font><font color="#007700">;<br />&nbsp;&nbsp;exit;<br />}<br /><br /></font><font color="#0000BB">$elements </font><font color="#007700">= </font><font color="#0000BB">$dom</font><font color="#007700">-&gt;</font><font color="#0000BB">get_elements_by_tagname</font><font color="#007700">(</font><font color="#DD0000">"informaltable"</font><font color="#007700">);<br /></font><font color="#0000BB">print_r</font><font color="#007700">(</font><font color="#0000BB">$elements</font><font color="#007700">);<br /></font><font color="#0000BB">$element </font><font color="#007700">= </font><font color="#0000BB">$elements</font><font color="#007700">[</font><font color="#0000BB">0</font><font color="#007700">];<br /><br /></font><font color="#0000BB">$newnode </font><font color="#007700">= </font><font color="#0000BB">$element</font><font color="#007700">-&gt;</font><font color="#0000BB">insert_before</font><font color="#007700">(</font><font color="#0000BB">$element</font><font color="#007700">, </font><font color="#0000BB">$element</font><font color="#007700">);<br /></font><font color="#0000BB">$children </font><font color="#007700">= </font><font color="#0000BB">$newnode</font><font color="#007700">-&gt;</font><font color="#0000BB">children</font><font color="#007700">();<br /></font><font color="#0000BB">$attr </font><font color="#007700">= </font><font color="#0000BB">$children</font><font color="#007700">[</font><font color="#0000BB">1</font><font color="#007700">]-&gt;</font><font color="#0000BB">set_attribute</font><font color="#007700">(</font><font color="#DD0000">"align"</font><font color="#007700">, </font><font color="#DD0000">"left"</font><font color="#007700">);<br /><br />echo </font><font color="#DD0000">"&lt;pre&gt;"</font><font color="#007700">;<br /></font><font color="#0000BB">$xmlfile </font><font color="#007700">= </font><font color="#0000BB">$dom</font><font color="#007700">-&gt;</font><font color="#0000BB">dump_mem</font><font color="#007700">();<br />echo </font><font color="#0000BB">htmlentities</font><font color="#007700">(</font><font color="#0000BB">$xmlfile</font><font color="#007700">);<br />echo </font><font color="#DD0000">"&lt;/pre&gt;"</font><font color="#007700">;<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
  </P
><P
>&#13;   See also <A
HREF="function.domnode-append-child.html"
><B
CLASS="function"
>domnode_append_child()</B
></A
>.
  </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.domnode-has-child-nodes.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.domnode-is-blank-node.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>DomNode-&#62;has_child_nodes</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.domxml.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>DomNode-&#62;is_blank_node</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>