CSharp examples for System.Xml:XML Document
Add an XML attribute to an element
/*/*from w w w. jav a2 s. c om*/ * Copyright (C) 2006-2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography; using System.Security.Cryptography; using System.Data; using System.ComponentModel; using System.Security; using System.Collections; using System.Configuration; using System.Security.Principal; using System.IO; using System.Net; using System.Collections.Specialized; using System.Web; using System.Xml; using System.Globalization; using System; public class Main{ /// <summary> /// Method to add an XML attribute to an element /// </summary> /// <param name="node"></param> /// <param name="name"></param> /// <param name="value"></param> public static void AddAttribute(XmlNode node, String name, String value) { XmlAttribute attr = node.OwnerDocument.CreateAttribute(name); attr.Value = value; node.Attributes.Append(attr); } }