cvs: phpdoc /en/reference/dom/domdocument createelementns.xml

From: Date: Fri, 22 May 2009 07:47:33 +0000
Subject: cvs: phpdoc /en/reference/dom/domdocument createelementns.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4052@lists.php.net to get a copy of this message
bjori Fri May 22 07:47:33 2009 UTC Modified files: /phpdoc/en/reference/dom/domdocument createelementns.xml Log: Add another example by scott at thebrain dot ca (see bug#48312) http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/dom/domdocument/createelementns.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/dom/domdocument/createelementns.xml diff -u phpdoc/en/reference/dom/domdocument/createelementns.xml:1.3 phpdoc/en/reference/dom/domdocument/createelementns.xml:1.4 --- phpdoc/en/reference/dom/domdocument/createelementns.xml:1.3 Sun Dec 16 13:18:07 2007 +++ phpdoc/en/reference/dom/domdocument/createelementns.xml Fri May 22 07:47:33 2009 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry xml:id="domdocument.createelementns" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>DOMDocument::createElementNS</refname> @@ -110,6 +110,41 @@ ]]> </screen> </example> + <example> + <title>A namespace prefix example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = new DOMDocument('1.0', 'utf-8'); +$doc->formatOutput = true; +$root = $doc->createElementNS('http://www.w3.org/2005/Atom', 'element'); +$doc->appendChild($root); +$root->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:g', 'http://base.google.com/ns/1.0'); +$item = $doc->createElementNS('http://base.google.com/ns/1.0', 'g:item_type', 'house'); +$root->appendChild($item); + +echo $doc->saveXML(), "\n"; + +echo $item->namespaceURI, "\n"; // Outputs: http://base.google.com/ns/1.0 +echo $item->prefix, "\n"; // Outputs: g +echo $item->localName, "\n"; // Outputs: item_type +?> +]]> + </programlisting> + &example.outputs; + <screen role="xml"> +<![CDATA[ +<?xml version="1.0" encoding="utf-8"?> +<element xmlns="http://www.w3.org/2005/Atom" xmlns:g="http://base.google.com/ns/1.0"> + <g:item_type>house</g:item_type> +</element> + +http://base.google.com/ns/1.0 +g +item_type +]]> + </screen> + </example> </para> </refsect1> <refsect1 role="seealso">

« previous php.doc.cvs (#4052) next »