{"id":390,"date":"2025-03-05T09:48:42","date_gmt":"2025-03-05T00:48:42","guid":{"rendered":"https:\/\/xslt.auctionpro.co.kr\/?p=390"},"modified":"2025-03-05T09:48:44","modified_gmt":"2025-03-05T00:48:44","slug":"xml-node-%ec%97%90-attribute-%ec%b6%94%ea%b0%80","status":"publish","type":"post","link":"https:\/\/xslt.auctionpro.co.kr\/?p=390","title":{"rendered":"Xml node \uc5d0 Attribute \ucd94\uac00"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview :  \uac04\ub2e8\ud55c 2\uac00\uc9c0<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">1. LINQ to XML \uc0ac\uc6a9<\/h3>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" title=\"LINQ\" >using System;\nusing System.Xml.Linq;\n\nclass Program\n{\n    static void Main()\n    {\n        string xml = @\"&lt;NewDataSet&gt;\n\t&lt;DATA&gt;\n\t\t&lt;idx&gt;26182&lt;\/idx&gt;\n\t\t&lt;ID&gt;ID88RK&lt;\/ID&gt;\n\t\t&lt;KeyName&gt;Dave&lt;\/KeyName&gt;\n\t&lt;\/DATA&gt;\n&lt;\/NewDataSet&gt;\";\n\n        \/\/ XML \ubb38\uc790\uc5f4\uc744 XDocument\ub85c \ud30c\uc2f1\n        XDocument xdoc = XDocument.Parse(xml);\n\n        \/\/ &lt;DATA&gt; \uc694\uc18c \ucc3e\uae30\n        XElement DATAElement = xdoc.Root.Element(\"DATA\");\n        if (DATAElement != null)\n        {\n            \/\/ Number \uc18d\uc131 \ucd94\uac00\n            DATAElement.SetAttributeValue(\"Number\", \"1232323\");\n        }\n\n        \/\/ \uc218\uc815\ub41c XML \ucd9c\ub825\n        Console.WriteLine(xdoc);\n    }\n}\n<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2. XmlDocument \uc0ac\uc6a9<\/h3>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:xhtml decode:true \" title=\"xml\" >using System;\nusing System.Xml;\n\nclass Program\n{\n    static void Main()\n    {\nstring xml = @\"&lt;NewDataSet&gt;\n\t&lt;DATA&gt;\n\t\t&lt;idx&gt;26182&lt;\/idx&gt;\n\t\t&lt;ID&gt;ID88RK&lt;\/ID&gt;\n\t\t&lt;KeyName&gt;Dave&lt;\/KeyName&gt;\n\t&lt;\/DATA&gt;\n&lt;\/NewDataSet&gt;\";\n\n        \/\/ XmlDocument \uac1d\uccb4 \uc0dd\uc131 \ud6c4 XML \ub85c\ub4dc\n        XmlDocument doc = new XmlDocument();\n        doc.LoadXml(xml);\n\n        \/\/ XPath\ub97c \uc774\uc6a9\ud558\uc5ec &lt;EMD&gt; \uc694\uc18c \uc120\ud0dd\n        XmlNode emdNode = doc.SelectSingleNode(\"\/NewDataSet\/DATA\");\n        if (dataNode != null)\n        {\n            \/\/ TicketNumber \uc18d\uc131 \uc0dd\uc131 \ubc0f \uac12 \uc124\uc815\n            XmlAttribute attr = doc.CreateAttribute(\"Number\");\n            attr.Value = \"1232323\";\n            dataNode.Attributes.Append(attr);\n        }\n\n        \/\/ \uc218\uc815\ub41c XML \ucd9c\ub825\n        Console.WriteLine(doc.OuterXml);\n    }\n}\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview : \uac04\ub2e8\ud55c 2\uac00\uc9c0 1. LINQ to XML \uc0ac\uc6a9 2. XmlDocument \uc0ac\uc6a9<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-390","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/390","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=390"}],"version-history":[{"count":1,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/390\/revisions"}],"predecessor-version":[{"id":391,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/390\/revisions\/391"}],"wp:attachment":[{"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=390"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=390"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xslt.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=390"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}