Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 2316

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Working with XML namespaces</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="example.xmlwriter-simple.html">Creating a simple XML document</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="example.xmlwriter-oop.html">Working with the OO API</a></div>
 <div class="up"><a href="xmlwriter.examples.html">Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="example.xmlwriter-namespace" class="section">
  <h2 class="title">Working with XML namespaces</h2>
  <p class="para">
   This example shows how to create namespaced XML elements.
  </p>
  <p class="para">
   <div class="example" id="example-6757">
    <p><strong>Example #1 Working with XML namespaces</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$xw&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xmlwriter_open_memory</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">xmlwriter_set_indent</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">xmlwriter_set_indent_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'&nbsp;'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xmlwriter_start_document</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'1.0'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'UTF-8'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;A&nbsp;first&nbsp;element<br /></span><span style="color: #0000BB">xmlwriter_start_element_ns</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,</span><span style="color: #DD0000">'prefix'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'books'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'uri'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xmlwriter_start_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'isbn'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xmlwriter_start_attribute_ns</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'prefix'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'isbn'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'uri'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xmlwriter_end_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xmlwriter_end_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xmlwriter_text</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'book1'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">xmlwriter_end_element</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">xmlwriter_end_document</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">xmlwriter_output_memory</span><span style="color: #007700">(</span><span style="color: #0000BB">$xw</span><span style="color: #007700">);</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;prefix:books isbn=&quot;&quot; prefix:isbn=&quot;&quot; xmlns:prefix=&quot;uri&quot;&gt;book1&lt;/prefix:books&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="example.xmlwriter-simple.html">Creating a simple XML document</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="example.xmlwriter-oop.html">Working with the OO API</a></div>
 <div class="up"><a href="xmlwriter.examples.html">Examples</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>