⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.xml-parse-into-struct.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Parse XML data into an array structure</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.xml-get-error-code.html">xml_get_error_code</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.xml-parse.html">xml_parse</a></div> <div class="up"><a href="ref.xml.html">XML Parser Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.xml-parse-into-struct" class="refentry"> <div class="refnamediv">  <h1 class="refname">xml_parse_into_struct</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">xml_parse_into_struct</span> &mdash; <span class="dc-title">Parse XML data into an array structure</span></p> </div>  <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">int</span> <span class="methodname"><b><b>xml_parse_into_struct</b></b></span>    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$parser</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$data</tt></span>   , <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$values</tt></span>   [, <span class="methodparam"><span class="type">array</span> <tt class="parameter reference">&$index</tt></span>  ] )</div>  <p class="para rdfs-comment">   This function parses an XML file into 2 parallel array structures, one   (<i><tt class="parameter">index</tt></i>) containing pointers to the location of the   appropriate values in the <i><tt class="parameter">values</tt></i> array. These last   two parameters must be passed by reference.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">parser</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">data</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">values</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">index</tt></i></span>     <dd>      <p class="para">      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   <b>xml_parse_into_struct()</b> returns 0 for failure and 1 for   success. This is not the same as <b><tt>FALSE</tt></b> and <b><tt>TRUE</tt></b>, be careful with   operators such as ===.  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   Below is an example that illustrates the internal structure of   the arrays being generated by the function. We use a simple   <i>note</i> tag embedded inside a   <i>para</i> tag, and then we parse this and print out   the structures generated:   <div class="example">    <p><b>Example #1 <b>xml_parse_into_struct()</b> example</b></p>    <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$simple&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"&lt;para&gt;&lt;note&gt;simple&nbsp;note&lt;/note&gt;&lt;/para&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$p&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xml_parser_create</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">xml_parse_into_struct</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$simple</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$vals</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$index</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xml_parser_free</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Index&nbsp;array\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$index</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"\nVals&nbsp;array\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$vals</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>    <div class="example-contents"><p>     When we run that code, the output will be:    </p></div>    <div class="example-contents"><pre><div class="cdata"><pre>Index array

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -