コード例 #1
0
 /// <summary>
 /// Removes a Style.
 /// </summary>
 public void RemoveStyle(string id)
 {
     foreach (XmlNode styleNode in StylesNode.ChildNodes.Cast <XmlNode>().Where(node => node.LocalName == LocalNames.Style))
     {
         if (styleNode.Attributes["ss:ID"].Value == id)
         {
             StylesNode.RemoveChild(styleNode);
             return;
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Adds a Style. If a Style with the same id already exists, it is overwritten.
        /// </summary>
        /// <example>
        /// <![CDATA[
        /// <Styles>
        ///   <Style ss:ID="id">
        ///     <childName ss:childNameAttribute="childAttributeValue" />
        ///   </Style>
        /// </Styles>
        /// ]]>
        /// </example>
        public void AddStyle(string id, string childName, string childAttributeName, string childAttributeValue)
        {
            RemoveStyle(id);

            XmlNode styleNode = XmlDocument.CreateElement(LocalNames.Style, ROOT_NAMESPACE);

            StylesNode.AppendChild(styleNode);

            XmlAttribute idAttribute = XmlDocument.CreateAttribute("ss", "ID", PREFIX_NAMESPACEURI["ss"]);

            idAttribute.Value = id;
            styleNode.Attributes.Append(idAttribute);

            XmlNode      childNode      = XmlDocument.CreateElement(childName, ROOT_NAMESPACE);
            XmlAttribute childAttribute = XmlDocument.CreateAttribute("ss", childAttributeName, PREFIX_NAMESPACEURI["ss"]);

            childAttribute.Value = childAttributeValue;
            childNode.Attributes.Append(childAttribute);
            styleNode.AppendChild(childNode);
        }