downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/simplexmlelement.attributes.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/class.simplexmlelement.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'simplexmlelement.attributes.php',
   
1 => 'SimpleXMLElement::attributes',
  ),
 
'up' =>
  array (
   
0 => 'class.simplexmlelement.php',
   
1 => 'The SimpleXMLElement class',
  ),
 
'prev' =>
  array (
   
0 => 'simplexmlelement.asXML.php',
   
1 => 'SimpleXMLElement::asXML',
  ),
 
'next' =>
  array (
   
0 => 'simplexmlelement.children.php',
   
1 => 'SimpleXMLElement::children',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="simplexmlelement.attributes" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLElement::attributes</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.1)</p><p class="refpurpose"><span class="refname">SimpleXMLElement::attributes</span> &mdash; <span class="dc-title">Identifies an element&#039;s attributes</span></p>

 </div>
 
 <a name="simplexmlelement.attributes.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="classsynopsis">
   <div class="ooclass"><a href="class.simplexmlelement.php" class="classname">SimpleXMLElement</a></div>
   <div class="methodsynopsis dc-description">
    <span class="type">SimpleXMLElement</span> <span class="methodname"><b>attributes</b></span>
     ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$ns</tt></span>
    [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$is_prefix</tt></span>
   ]] )</div>

  </div>
  <p class="para">
   This function provides the attributes and values defined within an xml tag.
  </p>
  <blockquote><p><b class="note">Note</b>: <span class="simpara">SimpleXML has made a rule of adding
iterative properties to most methods. They cannot be viewed using <a href="function.var-dump.php" class="function">var_dump()</a>
or anything else which can examine objects.</span></p></blockquote>
 </div>


 <a name="simplexmlelement.attributes.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">ns</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       An optional namespace for the retrieved attributes
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">is_prefix</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Default to <b><tt class="constant">FALSE</tt></b>
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="simplexmlelement.attributes.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
  </p>
 </div>


 <a name="simplexmlelement.attributes.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 Interpret an XML string</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$string&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;a&nbsp;xmlns:b&gt;<br />&nbsp;&lt;foo&nbsp;name="one"&nbsp;game="lonely"&gt;1&lt;/foo&gt;<br />&lt;/a&gt;<br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$xml&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">simplexml_load_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br />foreach(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">foo</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">attributes</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">,</span><span style="color: #DD0000">'="'</span><span style="color: #007700">,</span><span style="color: #0000BB">$b</span><span style="color: #007700">,</span><span style="color: #DD0000">"\"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
name=&quot;one&quot;
game=&quot;lonely&quot;
</pre></div>
    </div>
   </div><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites