Welcome to the Cookbook

loading...

7.12.2 elem

The original text for this section has changed since it was translated. Please help resolve this difference. You can:

More information about translations

elem メソッドもまた、アトリビュートと中のコンテンツで XML ノードを作成します。

string elem (string $name, $attrib = array(), mixed $content = null, $endTag = true)

echo $xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
// <myNameSpace:count>content</count> を生成する
  1. echo $xml->elem('count', array('namespace' => 'myNameSpace'), 'content');
  2. // <myNameSpace:count>content</count> を生成する

もし文字列のノードを CDATA でラップしたいなら、第三引数に「cdata」と「value」というキーを持つ配列を渡してください。

echo $xml->elem('count', null, array('cdata'=>true,'value'=>'content');
// <count><![CDATA[content]]></count> を生成する
  1. echo $xml->elem('count', null, array('cdata'=>true,'value'=>'content');
  2. // <count><![CDATA[content]]></count> を生成する