<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>XML on ゲンゾウ用ポストイット</title><link>https://genzouw.com/entry/category/xml/</link><description>Recent content in XML on ゲンゾウ用ポストイット</description><generator>Hugo</generator><language>ja</language><lastBuildDate>Mon, 27 Apr 2009 21:54:00 +0900</lastBuildDate><atom:link href="https://genzouw.com/entry/category/xml/index.xml" rel="self" type="application/rss+xml"/><item><title>Groovy＋Xml（その１：XmlSlurperとXmlParserの違い）</title><link>https://genzouw.com/entry/2009/04/27/215400/343/</link><pubDate>Mon, 27 Apr 2009 21:54:00 +0900</pubDate><guid>https://genzouw.com/entry/2009/04/27/215400/343/</guid><description>&lt;p&gt;XmlSlurperとXmlParser、両者はいずれもxmlをパースするクラスですがなにが違うのかなとおもい調べてみた。&lt;/p&gt;&#10;&lt;p&gt;大きな違いは以下のようになっている（参考：&lt;a href="http://docs.codehaus.org/display/GROOVY/Processing+XML"&gt;Processing XML - Groovy - Codehaus&lt;/a&gt;）&lt;/p&gt;&#10;&lt;table data-border="1" style="width: 574px; height: 127px;"&gt;&#10;&lt;colgroup&gt;&#10;&lt;col style="width: 50%" /&gt;&#10;&lt;col style="width: 50%" /&gt;&#10;&lt;/colgroup&gt;&#10;&lt;tbody&gt;&#10;&lt;tr&gt;&#10;&lt;th data-bgcolor="#ffffcc" scope="row"&gt;&lt;a href="http://docs.codehaus.org/display/GROOVY/Reading+XML+using+Groovy%27s+XmlParser" title="Reading XML using Groovy&amp;#39;s XmlParser"&gt;XmlParser&lt;/a&gt;&lt;/th&gt;&#10;&lt;td&gt;&lt;p&gt;supports GPath expressions for XML documents and allows updating&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;xml文書のGPath表現をサポートしているし、文書の更新も可能だよ&lt;/em&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr&gt;&#10;&lt;th data-bgcolor="#ffffcc" scope="row"&gt;&lt;a href="http://docs.codehaus.org/display/GROOVY/Reading+XML+using+Groovy%27s+XmlSlurper" title="Reading XML using Groovy&amp;#39;s XmlSlurper"&gt;XmlSlurper&lt;/a&gt;&lt;/th&gt;&#10;&lt;td&gt;&lt;p&gt;lower overheads than XmlParser due to lazy evaluation but only supports read operations&lt;/p&gt;&#10;&lt;p&gt;&lt;em&gt;遅延処理を利用してXmlParserよりもオーバーヘッドが少ないが、読み込み処理しかサポートしてないよ&lt;/em&gt;&lt;/p&gt;&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;xmlで記述した初期設定を読み込むような書き込みのない処理には&lt;strong&gt;XmlSlurper&lt;/strong&gt;が向いているようです。&lt;/p&gt;&#10;&lt;p&gt;逆にxmlをよみこんで要素を修正し、出力する、といった場合には&lt;strong&gt;XmlParser&lt;/strong&gt;の方がよいみたい。&lt;/p&gt;</description></item></channel></rss>