<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >domxml_open_mem</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 XML Functions" HREF="ref.domxml.html"><LINK REL="PREVIOUS" TITLE="domxml_open_file" HREF="function.domxml-open-file.html"><LINK REL="NEXT" TITLE="domxml_version" HREF="function.domxml-version.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.domxml-open-file.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.domxml-version.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.domxml-open-mem" ></A >domxml_open_mem</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN45616" ></A ><P > (PHP 4 >= 4.2.1, PECL)</P >domxml_open_mem -- Creates a DOM object of an XML document</DIV ><DIV CLASS="refsect1" ><A NAME="AEN45619" ></A ><H2 >说明</H2 >DomDocument <B CLASS="methodname" >domxml_open_mem</B > ( string str [, int mode [, array &error]] )<BR ></BR ><P > The function parses the XML document in the given string. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN45634" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >str</CODE ></DT ><DD ><P > The contents of the XML file. </P ></DD ><DT ><CODE CLASS="parameter" >mode</CODE ></DT ><DD ><P > This optional parameter can be used to change the behavior of this function. </P ><P > You can use one of the following constants for it: <TT CLASS="constant" ><B >DOMXML_LOAD_PARSING</B ></TT > (default), <TT CLASS="constant" ><B >DOMXML_LOAD_VALIDATING</B ></TT > or <TT CLASS="constant" ><B >DOMXML_LOAD_RECOVERING</B ></TT >. You can add to it also <TT CLASS="constant" ><B >DOMXML_LOAD_DONT_KEEP_BLANKS</B ></TT >, <TT CLASS="constant" ><B >DOMXML_LOAD_SUBSTITUTE_ENTITIES</B ></TT > and <TT CLASS="constant" ><B >DOMXML_LOAD_COMPLETE_ATTRS</B ></TT > by <A HREF="language.operators.bitwise.html" >bitwise or</A >. </P ></DD ><DT ><CODE CLASS="parameter" >error</CODE ></DT ><DD ><P > If used, it will contain the error messages. <CODE CLASS="parameter" >error</CODE > must be passed in by <A HREF="language.references.html" >reference</A >. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN45663" ></A ><H2 >返回值</H2 ><P > Returns a <B CLASS="classname" >DomDocument</B > instance of the given XML contents. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN45667" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN45670" ></A ><P ><B >例 1. Opening an XML document in a string</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?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 /> echo </font><font color="#DD0000">"Error while parsing the document\n"</font><font color="#007700">;<br /> exit;<br />}<br /><br /></font><font color="#0000BB">$root </font><font color="#007700">= </font><font color="#0000BB">$dom</font><font color="#007700">-></font><font color="#0000BB">document_element</font><font color="#007700">();<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN45673" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.domxml-open-file.html" ><B CLASS="function" >domxml_open_file()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.domxml-new-doc.html" ><B CLASS="function" >domxml_new_doc()</B ></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.domxml-open-file.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.domxml-version.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >domxml_open_file</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.domxml.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >domxml_version</TD ></TR ></TABLE ></DIV ></BODY ></HTML >