{"id":3626,"date":"2012-08-08T10:27:02","date_gmt":"2012-08-07T16:27:02","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/3626"},"modified":"2012-08-08T10:41:47","modified_gmt":"2012-08-08T01:41:47","slug":"c-xelement-%e9%a2%a8%e3%81%ab-xml-%e3%82%92%e6%a7%8b%e7%af%89%e3%81%99%e3%82%8b%e3%82%af%e3%83%a9%e3%82%b9%e3%82%92%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/3626","title":{"rendered":"[C#] XElement \u98a8\u306b XML \u3092\u69cb\u7bc9\u3059\u308b\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u307f\u308b"},"content":{"rendered":"<p>\n\u56f0\u3063\u305f\u3068\u304d\u306b\u305d\u306e\u307e\u307e\u4f7f\u3048\u308b LINQ to XML \u30b3\u30fc\u30c9\u30b5\u30f3\u30d7\u30eb 18 \u30d1\u30bf\u30fc\u30f3 [1\/2] &#8211; Web\/DB \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5fb9\u5e95\u89e3\u8aac<br \/>\n<a href=\"http:\/\/keicode.com\/dotnet\/linq-to-xml-101.php\">http:\/\/keicode.com\/dotnet\/linq-to-xml-101.php<\/a><br \/>\nXElement \u30af\u30e9\u30b9 (System.Xml.Linq)<br \/>\n<a href=\"http:\/\/msdn.microsoft.com\/ja-jp\/library\/system.xml.linq.xelement.aspx\">http:\/\/msdn.microsoft.com\/ja-jp\/library\/system.xml.linq.xelement.aspx<\/a>\n<\/p>\n<p>\n\u3092\u53c2\u8003\u306b\u3057\u306a\u304c\u3089\u3001XML \u3092\u30e1\u30bd\u30c3\u30c9\u30c1\u30a7\u30fc\u30f3\u3092\u4f7f\u3063\u3066\u69cb\u7bc9\u3059\u308b\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3059\u3002\u307e\u3041\u3001HtmlDom \u3092\u4f5c\u308b\u3068\u304d\u306e\u526f\u7523\u7269&#8230;\u3068\u8a00\u3046\u304b\u3001\u7df4\u7fd2\u554f\u984c\u7684\u306b\u3002\n<\/p>\n<p>\n\u25a0\u4f7f\u3044\u65b9\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u308b\n<\/p>\n<p>\nTDD \u3068 UIDD \u306e\u30cf\u30a4\u30d6\u30ea\u30c3\u30c9\u30d7\u30ed\u30bb\u30b9\uff08\u3068\u3044\u3046\u547d\u540d\u3092\u3057\u3066\u304a\u304f\uff09\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u4f7f\u3044\u65b9\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u5148\u306b\u4f5c\u308a\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u5148\u306b\u4f5c\u3063\u3066\u304a\u304f\u3068\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u30de\u30cb\u30e5\u30a2\u30eb\u304c\u306a\u304f\u3066\u3082\u4f7f\u3048\u308b\u300c\u611f\u899a\u7684\u306b\u6b63\u3057\u3044\u300d\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b3\u30fc\u30c9\u304c\u3067\u304d\u3042\u304c\u308a\u307e\u3059\u3002D.A.\u30ce\u30fc\u30de\u30f3\u306e\u8a00\u3046\u300c\u30e6\u30fc\u30b6\u30fc\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u300d\u3063\u3066\u3084\u3064\u3067\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic void test1()\r\n{\r\n\tvar root = new XmlNode(&quot;root&quot;)\r\n\t\t.Node(&quot;person&quot;)\r\n\t\t.Node(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.Root;\r\n\r\n\tvar root2 = new XmlNode(&quot;root&quot;)\r\n\t\t.Node(&quot;person&quot;)\r\n\t\t.AddNode(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.AddNode(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.AddNode(&quot;address&quot;, &quot;itabashi-ku&quot;)\r\n\t\t.Root;\r\n\r\n\tvar root3 = new XmlNode(&quot;root&quot;)\r\n\t\t.Node(&quot;person&quot;)\r\n\t\t.AddAttr(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.AddAttr(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.SetValue(&quot;masuda tomoaki&quot;)\r\n\t\t.Root;\r\n\r\n\r\n\tvar root4 = new XmlNode(&quot;persons&quot;)\r\n\t\t.Node(&quot;person&quot;).AddAttr(&quot;id&quot;, &quot;1&quot;)\r\n\t\t\t.AddNode(&quot;name&quot;, &quot;masuda tomoaki&quot;)\r\n\t\t\t.AddNode(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.Parent\r\n\t\t.Node(&quot;person&quot;).AddAttr(&quot;id&quot;, &quot;2&quot;)\r\n\t\t\t.AddNode(&quot;name&quot;, &quot;yamada taro&quot;)\r\n\t\t\t.AddNode(&quot;age&quot;, &quot;20&quot;)\r\n\t\t.Root;\r\n}\r\n<\/pre>\n<p>\n\u5b9f\u306f\u3001.Parent \u3068 .Root \u306f\u5f8c\u4ed8\u3001SetValue \u306f\u3084\u3080\u306a\u304f\u3063\u3066\u611f\u3058\u3067\u3059\u306d\u3002<br \/>\n\u6700\u521d\u306b\u4f5c\u3063\u305f\u306e\u306f\u3053\u3093\u306a\u611f\u3058\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tvar root = new XmlNode(&quot;root&quot;)\r\n\t\t.Node(&quot;person&quot;)\r\n\t\t.Attr(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.Attr(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.Value(&quot;masuda tomoaki&quot;);\r\n<\/pre>\n<p>\n\u300c\u52d5\u8a5e\u300d\u3092\u4f7f\u308f\u305a\u306b\u300c\u540d\u8a5e\u300d\u3060\u3051\u3067\u3001\u7e4b\u3052\u3066\u307f\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001Value \u30d7\u30ed\u30d1\u30c6\u30a3\u3068\u3001Value \u30e1\u30bd\u30c3\u30c9\u304c\u66d6\u6627\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u30d1\u30b9\u3002<br \/>\n\u3042\u3068\u3001\u5b50\u30ce\u30fc\u30c9\u3092\u9023\u7d9a\u8ffd\u52a0\u3059\u308b\u6642\u306b Node \u3060\u3051\u3060\u3068\u99c4\u76ee\u3067\u3001Node.Parent.Node(&#8220;tag&#8221;) \u3068\u5909\u306a\u3053\u3068\u3092\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u3001AddNode \u306b\u5909\u66f4\u3002\u305d\u308c\u306b\u4f34\u3063\u3066\u3001Attr \u3082 AddAttr \u306b\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002\n<\/p>\n<p>\n\u305d\u308c\u3068\u3001\u6700\u5f8c\u306b Root \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5165\u308c\u305f\u306e\u306f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3068\u304d\u306b\u3001\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tvar root = new XmlNode(&quot;root&quot;);\r\n\troot.Node(&quot;person&quot;)\r\n\t\t.Attr(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.Attr(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.Value(&quot;masuda tomoaki&quot;);\r\n    Assert.AreEqual(&quot;...&quot;, root.Xml );\r\n<\/pre>\n<p>\n\u306e\u3088\u3046\u306b\u300c\u308f\u3056\u308f\u3056\u300d\u30eb\u30fc\u30c8\u8981\u7d20\u3092\u4fdd\u5b58\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3068\u3044\u3046\u9762\u5012\u304c\u3042\u308b\u306e\u3067\u3001\u30eb\u30fc\u30c8\u306b\u623b\u3059\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u7528\u610f\u3057\u307e\u3059\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\tvar root = new XmlNode(&quot;root&quot;)\r\n\t    .Node(&quot;person&quot;)\r\n\t\t.Attr(&quot;name&quot;, &quot;masuda&quot;)\r\n\t\t.Attr(&quot;age&quot;, &quot;44&quot;)\r\n\t\t.Value(&quot;masuda tomoaki&quot;)\r\n        .Root ;\r\n    Assert.AreEqual(&quot;...&quot;, root.Xml );\r\n<\/pre>\n<p>\n\u3053\u3063\u3061\u306e\u307b\u3046\u304c\u3059\u3063\u304d\u308a\u3059\u308b\u3057\u3001\u5f8c\u304b\u3089\u610f\u5473\u304c\u5206\u304b\u308a\u6613\u3044\u306e\u3067\u3059\u3002\n<\/p>\n<p>\n\u25a0\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u306b\u5f93\u3063\u3066\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u304c\u901a\u308b\u3088\u3046\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\n<\/p>\n<p>\n\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u5148\u306b\u66f8\u3044\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001Visual Studio \u306e\u30a4\u30f3\u30c6\u30ea\u30bb\u30f3\u30b9\u3092\u5229\u7528\u3057\u305f\u3044\u306e\u3067\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u304c\u901a\u308b\u307e\u3067\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u304d\u307e\u3059\u3002<br \/>\n\u7d20\u306e\u30a8\u30c7\u30a3\u30bf\u3067\u66f8\u304f\u3068\u304d\u306f\u3001\u9006\u306b\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u66f8\u3044\u305f\u308a\u3057\u307e\u3059\u3002\u3068\u8a00\u3046\u306e\u3082\u3001\u7d20\u306e\u30a8\u30c7\u30a3\u30bf\u306e\u5834\u5408\u306f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u306e\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\u304b\u3089\u30e1\u30bd\u30c3\u30c9\/\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u306b\u306a\u308b\u306e\u3067\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304c\u5148\u306e\u307b\u3046\u304c\u3084\u308a\u6613\u3044\u306e\u3067\u3059\u3002<br \/>\n\u3053\u306e\u9055\u3044\u306f\uff08\u79c1\u306b\u3068\u3063\u3066\uff09\u91cd\u8981\u3067\u3059\u3002\n<\/p>\n<p>\n\u25a0\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\n<\/p>\n<p>\n\u4e0b\u8a18\u3067\u306f\u3001\u4e00\u6c17\u306b\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5b9f\u969b\u306b\u306f\u3072\u3068\u3064\u3072\u3068\u3064\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u7c21\u5358\u306a\u30c6\u30b9\u30c8\u304b\u3089\u8907\u96d1\u306a\u30c6\u30b9\u30c8\u3078\u3068\u3044\u3046\u306e\u306f\u30c6\u30b9\u30c8\u306e\u5b9a\u756a\u3067\u3059\u3002<br \/>\n\u5b9f\u306f Xml \u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3068\u304d\u306b\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u3046\u3059\u308b\u3068\u30c6\u30b9\u30c8\u304c\u3084\u308a\u3084\u3059\u3044\u3067\u3059\u304b\u3089\u306d\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\t&#x5B;TestMethod]\r\n\tpublic void TestNormal1()\r\n\t{\r\n\t\tvar root = new XmlNode(&amp;quot;root&amp;quot;)\r\n\t\t\t.Node(&amp;quot;person&amp;quot;)\r\n\t\t\t.Node(&amp;quot;name&amp;quot;, &amp;quot;masuda&amp;quot;)\r\n\t\t\t.Root;\r\n\r\n\t\tAssert.AreEqual(&amp;quot;&lt;root&gt;&lt;person&gt;&lt;name&gt;masuda&lt;\/name&gt;&lt;\/person&gt;&lt;\/root&gt;&amp;quot;, root.Xml);\r\n\t}\r\n\r\n\t&#x5B;TestMethod]\r\n\tpublic void TestNormal2()\r\n\t{\r\n\t\tvar root = new XmlNode(&amp;quot;root&amp;quot;)\r\n\t\t\t.Node(&amp;quot;person&amp;quot;)\r\n\t\t\t.AddNode(&amp;quot;name&amp;quot;, &amp;quot;masuda&amp;quot;)\r\n\t\t\t.AddNode(&amp;quot;age&amp;quot;, &amp;quot;44&amp;quot;)\r\n\t\t\t.AddNode(&amp;quot;address&amp;quot;, &amp;quot;itabashi-ku&amp;quot;)\r\n\t\t\t.Root;\r\n\r\n\t\tAssert.AreEqual(&amp;quot;&lt;root&gt;&lt;person&gt;&lt;name&gt;masuda&lt;\/name&gt;&lt;age&gt;44&lt;\/age&gt;&lt;address&gt;itabashi-ku&lt;\/address&gt;&lt;\/person&gt;&lt;\/root&gt;&amp;quot;, root.Xml);\r\n\t}\r\n\r\n\t&#x5B;TestMethod]\r\n\tpublic void TestNormal3()\r\n\t{\r\n\t\tvar root = new XmlNode(&amp;quot;root&amp;quot;)\r\n\t\t\t.Node(&amp;quot;person&amp;quot;)\r\n\t\t\t.AddAttr(&amp;quot;name&amp;quot;, &amp;quot;masuda&amp;quot;)\r\n\t\t\t.AddAttr(&amp;quot;age&amp;quot;, &amp;quot;44&amp;quot;)\r\n\t\t\t.SetValue(&amp;quot;masuda tomoaki&amp;quot;)\r\n\t\t\t.Root;\r\n\r\n\t\tAssert.AreEqual(&amp;quot;&lt;root&gt;&lt;person name=\\&amp;quot;masuda\\&amp;quot; age=\\&amp;quot;44\\&amp;quot;&gt;masuda tomoaki&lt;\/person&gt;&lt;\/root&gt;&amp;quot;, root.Xml);\r\n\t}\r\n\r\n\t&#x5B;TestMethod]\r\n\tpublic void TestNormal4()\r\n\t{\r\n\t\tvar root = new XmlNode(&amp;quot;persons&amp;quot;)\r\n\t\t\t.Node(&amp;quot;person&amp;quot;).AddAttr(&amp;quot;id&amp;quot;, &amp;quot;1&amp;quot;)\r\n\t\t\t\t.AddNode(&amp;quot;name&amp;quot;, &amp;quot;masuda tomoaki&amp;quot;)\r\n\t\t\t\t.AddNode(&amp;quot;age&amp;quot;, &amp;quot;44&amp;quot;)\r\n\t\t\t.Parent\r\n\t\t\t.Node(&amp;quot;person&amp;quot;).AddAttr(&amp;quot;id&amp;quot;, &amp;quot;2&amp;quot;)\r\n\t\t\t\t.AddNode(&amp;quot;name&amp;quot;, &amp;quot;yamada taro&amp;quot;)\r\n\t\t\t\t.AddNode(&amp;quot;age&amp;quot;, &amp;quot;20&amp;quot;)\r\n\t\t\t.Root;\r\n\t\t\t;\r\n\r\n\t\tAssert.AreEqual(&amp;quot;&lt;person&gt;&amp;quot; + \r\n\t\t\t&amp;quot;&lt;person id=\\&amp;quot;1\\&amp;quot;&gt;&lt;name&gt;masuda tomoaki&lt;\/name&gt;&lt;age&gt;44&lt;\/age&gt;&lt;\/person&gt;&amp;quot; +\r\n\t\t\t&amp;quot;&lt;person id=\\&amp;quot;2\\&amp;quot;&gt;&lt;name&gt;tamada taro&lt;\/name&gt;&lt;age&gt;20&lt;\/age&gt;&lt;\/person&gt;&amp;quot; +\r\n\t\t\t&amp;quot;&lt;\/persons&gt;&amp;quot;,\r\n\t\t\troot.Xml);\r\n\t}\r\n<\/pre>\n<p>\n\u25a0\u30b3\u30fc\u30c9\u304c\u5b8c\u6210\u54c1\n<\/p>\n<p>\n\u3067\u3082\u3063\u3066\u3001\u30c6\u30b9\u30c8\u3092\u901a\u308b\u3088\u3046\u306b\u3057\u305f\u306e\u304c\u4ee5\u4e0b\u3001150\u884c\u7a0b\u5ea6\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/>\nXml \u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u3001HtmlDom \u304b\u3089\u30b3\u30d4\u30da\u3057\u3066\u3044\u308b\u306e\u3067\u3061\u3087\u3063\u3068\u7121\u99c4\u306a\u30b3\u30fc\u30c9\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u307e\u3041\u3053\u306e\u7a0b\u5ea6\u3067\u66f8\u3051\u308b\u306e\u3060\u304b\u3089 C# \u3063\u3066\u4fbf\u5229\u3084\u306a\u3041\u3001\u3068\u3002<br \/>\n\u3053\u308c\u3092 HtmlDom \u306b\u7d44\u307f\u5165\u308c\u308b\u304b\u3069\u3046\u304b\u601d\u6848\u4e2d\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ XML node class\r\n\/\/\/ &lt;\/summary&gt;\r\npublic class XmlNode\r\n{\r\n\t#region property\r\n\tpublic string TagName { get; set; }\r\n\tpublic string Value { get; set; }\r\n\tpublic XmlNodeCollection Children { get; set; }\r\n\tpublic XmlAttrCollection Attrs { get; set; }\r\n\tpublic XmlNode Parent { get; set; }\r\n\t#endregion\r\n\r\n\t#region constractor \r\n\tpublic XmlNode(string tag, string value = &amp;quot;&amp;quot;)\r\n\t{\r\n\t\tthis.TagName = tag;\r\n\t\tthis.Value = value;\r\n\t\tthis.Children = new XmlNodeCollection();\r\n\t\tthis.Children.Parent = this;\r\n\t\tthis.Attrs = new XmlAttrCollection();\r\n\t}\r\n\t#endregion\r\n\r\n\t#region creator for method chain\r\n\tpublic XmlNode Node(string tag, string value = &amp;quot;&amp;quot;)\r\n\t{\r\n\t\tvar nd = new XmlNode(tag, value);\r\n\t\tthis.Children.Add(nd);\r\n\t\treturn nd;\r\n\t}\r\n\tpublic XmlNode AddNode(string tag, string value = &amp;quot;&amp;quot;)\r\n\t{\r\n\t\tthis.Node(tag, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic XmlNode AddAttr(string key, string value)\r\n\t{\r\n\t\tthis.Attrs.Add(new XmlAttr(key, value));\r\n\t\treturn this;\r\n\t}\r\n\tpublic XmlNode SetValue(string value)\r\n\t{\r\n\t\tthis.Value = value;\r\n\t\treturn this;\r\n\t}\r\n\t#endregion\r\n\r\n\t#region xml string serialize\r\n\tpublic string Xml\r\n\t{\r\n\t\tget\r\n\t\t{\r\n                string s = &amp;quot;&amp;quot;;\r\n                if (this.TagName == &amp;quot;&amp;quot; || this.TagName == &amp;quot;#text&amp;quot; || this.TagName == &amp;quot;#comment&amp;quot;)\r\n                {\r\n                    s = this.Value.Trim();\r\n                }\r\n                else\r\n                {\r\n                    s += string.Format(&amp;quot;&lt;{0}&amp;quot;, this.TagName);\r\n                    foreach (var at in this.Attrs)\r\n                    {\r\n                        s += string.Format(&amp;quot; {0}=\\&amp;quot;{1}\\&amp;quot;&amp;quot;, at.Key, at.Value);\r\n                    }\r\n                    if (this.Children.Count &gt; 0)\r\n                    {\r\n                        s += &amp;quot;&gt;&amp;quot;;\r\n\t\t\t\t\ts += this.Value;\r\n                        foreach (var el in this.Children)\r\n                        {\r\n                            s += el.Xml;\r\n                        }\r\n                        s += string.Format(&amp;quot;&lt;\/{0}&gt;&amp;quot;, this.TagName);\r\n                    }\r\n\t\t\t\telse if (this.Value != &amp;quot;&amp;quot;)\r\n\t\t\t\t{\r\n\t\t\t\t\ts += &amp;quot;&gt;&amp;quot;;\r\n\t\t\t\t\ts += this.Value;\r\n\t\t\t\t\ts += string.Format(&amp;quot;&lt;\/{0}&gt;&amp;quot;, this.TagName);\r\n\t\t\t\t} \r\n\t\t\t\telse \r\n                    {\r\n                        s += &amp;quot;\/&gt;&amp;quot;;\r\n                    }\r\n                }\r\n                return s;\r\n\t\t}\r\n\t}\r\n\t#endregion\r\n\r\n\tpublic XmlNode Root\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tXmlNode nd = this;\r\n\t\t\twhile (nd.Parent != null)\r\n\t\t\t{\r\n\t\t\t\tnd = nd.Parent;\r\n\t\t\t}\r\n\t\t\treturn nd;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ XML node collection\r\n\/\/\/ &lt;\/summary&gt;\r\npublic class XmlNodeCollection : List&lt;XmlNode&gt; {\r\n\tpublic XmlNode Parent { get; set; }\r\n\tpublic new XmlNode Add(XmlNode nd) \r\n\t{\r\n\t\tbase.Add(nd);\r\n\t\tnd.Parent = this.Parent;\r\n\t\treturn nd;\r\n\t}\r\n\r\n}\r\n\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ XML attribute class\r\n\/\/\/ &lt;\/summary&gt;\r\npublic class XmlAttr\r\n{\r\n\tpublic string Key { get; set; }\r\n\tpublic string Value { get; set; }\r\n\r\n\tpublic XmlAttr(string key, string value)\r\n\t{\r\n\t\tthis.Key = key;\r\n\t\tthis.Value = value;\r\n\t}\r\n}\r\n\/\/\/ &lt;summary&gt;\r\n\/\/\/ XML Attribute collection\r\n\/\/\/ &lt;\/summary&gt;\r\npublic class XmlAttrCollection : List&lt;XmlAttr&gt; { }\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u56f0\u3063\u305f\u3068\u304d\u306b\u305d\u306e\u307e\u307e\u4f7f\u3048\u308b LINQ to XML \u30b3\u30fc\u30c9\u30b5\u30f3\u30d7\u30eb 18 \u30d1\u30bf\u30fc\u30f3 [1\/2] &#8211; Web\/DB \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5fb9\u5e95\u89e3\u8aac http:\/\/keicode.com\/dotnet\/linq-to-x &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/3626\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-3626","post","type-post","status-publish","format-standard","hentry","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3626","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=3626"}],"version-history":[{"count":1,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3626\/revisions"}],"predecessor-version":[{"id":3627,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/3626\/revisions\/3627"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=3626"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=3626"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=3626"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}