<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/xml.xsl" type="text/xsl"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>nulog, NULL::something : out of the headphone &gt; 2004 &gt; July &gt; 05 &gt; php no nanikore unco</title>
  <link href="http://lowreal.net/logs/2004/07/05/1"/>
  <icon>http://lowreal.net/img/banner.png</icon>
  <link rel="self" type="application/atom+xml" href="http://lowreal.net/logs/2004/07/05/1.atom"/>
  <link rel="alternate" type="application/xhtml+xml" href="http://lowreal.net/logs/2004/07/05/1.xhtml"/>
  <updated>2004-07-05T00:07:51+09:00</updated>
  <author>
    <name>cho45(砂糖)</name>
  </author>
  <id>http://lowreal.net/2004/07/05/1</id>
  <entry>
    <title>php no nanikore unco</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2004/07/05/1.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2004/07/05/1.xhtml"/>
    <updated>2004-07-05T00:07:51+09:00</updated>
    <published>2004-07-05T00:07:51+09:00</published>
    <id>http://lowreal.net/2004/07/05/1</id>
    <category term="prog"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>たまに他の言語やるとイテレータがないのと中途半端なオブジェクト指向にむかついてくるわけだが。</p>
        <pre title="DOM code on php4">
					$doc = domxml_open_mem($template); // $template は xml な文字列が入った変数。
					$xpc = xpath_new_context($doc);
					foreach ($ns as $prefix =&gt; $uri) { // $ns は prefix と namespace の連想配列
					$xpc-&gt;xpath_register_ns($prefix, $uri);
					}
					$xns = $xpc-&gt;xpath_eval("/rdf:RDF/cc:Work/dc:title");
					$ele = $xns-&gt;nodeset[0];
					$ele-&gt;append_child($doc-&gt;create_text_node("test"));
					/*
					上記3行を
					$xpc-&gt;xpath_eval("/rdf:RDF/cc:Work/dc:title")-&gt;nodeset[0]-&gt;append_child($doc-&gt;create_text_node("test"));
					と書きたい。
					*/</pre>
        <p>いちいち変数名考えるのがダルい。</p>
        <p>あと <code>domxml_open_mem()</code> と <code>xpath_new_context()</code> とかが並んで使えるのもなんか違和感あるんだよなぁ。ネームスペースないってことはモジュール間で名前がコリジョンしたらどうするんだろ。特に <code>include</code> とかしなくても使えるし……謎だ。自分で定義した関数がたまたまモジュールで定義されてたらエラーでるし（php は関数の再定義も無理）あるモジュールを有効にした環境と、無効にした環境でエラーがでたりでなかったりもするんだろうか？</p>
      </div>
    </content>
  </entry>
</feed>
