{"id":130,"date":"2013-03-20T17:31:18","date_gmt":"2013-03-20T08:31:18","guid":{"rendered":"http:\/\/cromi.com\/?p=130"},"modified":"2013-03-20T18:25:50","modified_gmt":"2013-03-20T09:25:50","slug":"c-xml-%ec%97%90-%ec%93%b0%ea%b3%a0-%ec%9d%bd%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/cromi.com\/?p=130","title":{"rendered":"C# xml \uc5d0 \uc4f0\uace0 \uc77d\uae30"},"content":{"rendered":"<p>\uae30\ubcf8 \uc801\uc778 using \ucd94\uac00<\/p>\n<pre lang=\"csharp\"> using System.Xml;<\/pre>\n<p>\uc4f0\uae30 \ubd80\ubd84<\/p>\n<pre lang=\"csharp\">\r\n\r\nprivate void SaveXML()\r\n{\r\n    string sFilePath = System.IO.Directory.GetCurrentDirectory();\r\n\r\n    try\r\n    {\r\n\tXmlWriterSettings settings = new XmlWriterSettings();\r\n\tsettings.Indent = true;\r\n\tsettings.NewLineOnAttributes = true;\r\n\tXmlWriter xmlWriter = XmlWriter.Create(sFilePath + \"\/config.xml\");\r\n\txmlWriter.WriteStartDocument();\r\n\r\n\txmlWriter.WriteStartElement(\"root\");\r\n\txmlWriter.WriteElementString(\"IP\", \"192.168.100.136\");\r\n\txmlWriter.WriteElementString(\"PORT\", \"3333\");\r\n\txmlWriter.WriteEndDocument();\r\n\r\n\txmlWriter.Flush();\r\n\txmlWriter.Close();\r\n    }\r\n    catch (Exception ex)\r\n    {\r\n\tMessageBox.Show(ex.ToString());\r\n    }\r\n}<\/pre>\n<p>\uc77d\uc5b4\uc624\uae30 \ubd80\ubd84<\/p>\n<pre lang=\"csharp\">\r\nprivate void LoadXML()\r\n{\r\n    string strIP = string.Empty;\r\n    string strPORT = string.Empty;\r\n\r\n    string sFilePath = System.IO.Directory.GetCurrentDirectory();\r\n\r\n    try\r\n    {\r\n\tif (File.Exists(sFilePath + \"\/config.xml\")) \/\/ \ud30c\uc77c \uc720\ubb34 \uac80\uc0ac\r\n\t{\r\n\t    XmlTextReader xmlReadData = new XmlTextReader(sFilePath + \"\/config.xml\");\r\n\r\n\t    while (xmlReadData.Read())\r\n\t    {\r\n\t\tif (xmlReadData.NodeType == XmlNodeType.Element)\r\n\t\t{\r\n\t\t    switch (xmlReadData.Name.ToUpper().Trim())\r\n\t\t    {\r\n\t\t\tcase \"IP\": strIP = xmlReadData.ReadString().ToString().Trim(); break;\r\n\t\t\tcase \"PORT\": strPORT = xmlReadData.ReadString().ToString().Trim(); break;\r\n\t\t    }\r\n\t\t}\r\n\t    }\r\n\t    xmlReadData.Close();\r\n\r\n\t    textBox1.Text = strIP;\r\n\t    textBox2.Text = strPORT;\r\n\t}\r\n\telse \/\/ xml \ud30c\uc77c \ubbf8\uc874\uc7ac \uc2dc\r\n\t{                    \r\n\t    SaveXML();\r\n\t}\r\n    }\r\n    catch (Exception ex)\r\n    {\r\n\tMessageBox.Show(ex.ToString());\r\n    }\r\n}<\/pre>\n<p>\uc2e4\ud589 \uacb0\uacfc  <\/p>\n<p><a href=\"http:\/\/cromi.com\/wp-content\/uploads\/2013\/03\/xml.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/cromi.com\/wp-content\/uploads\/2013\/03\/xml.png\" alt=\"xml\" width=\"148\" height=\"60\" class=\"alignnone size-full target=\"_blank\" wp-image-131\" \/><\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>\uae30\ubcf8 \uc801\uc778 using \ucd94\uac00 using System.Xml; \uc4f0\uae30 \ubd80\ubd84 private void SaveXML() { string sFilePath = System.IO.Directory.GetCurrentDirectory(); try { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.NewLineOnAttributes = true; XmlWriter xmlWriter = XmlWriter.Create(sFilePath + &#8220;\/config.xml&#8221;); xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement(&#8220;root&#8221;); xmlWriter.WriteElementString(&#8220;IP&#8221;, &#8220;192.168.100.136&#8221;); xmlWriter.WriteElementString(&#8220;PORT&#8221;, &#8220;3333&#8221;); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } \uc77d\uc5b4\uc624\uae30 \ubd80\ubd84 private [&hellip;]<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[16,49,53,48,50,52,51],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-vs2008","tag-c","tag-c-xml","tag-vs2008-2","tag-xml"],"_links":{"self":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":3,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":134,"href":"http:\/\/cromi.com\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/134"}],"wp:attachment":[{"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cromi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}