OneNoteConversionTool.OutputGenerator.OneNoteGenerator.SetPageAttribute C# (CSharp) Method

SetPageAttribute() public method

Sets the page attribute to the given value
public SetPageAttribute ( string pageId, string attr, string value ) : void
pageId string ID of the page
attr string The attribute of interest
value string The new value of the attribute
return void
		public void SetPageAttribute(string pageId, string attr, string value)
		{
			try
			{
				// get the page
				XmlDocument doc = GetPageContent(pageId);
				XmlNode page = doc.DocumentElement;
				if (page == null || page.Attributes == null) return;
				if (page.Attributes[attr] == null)
				{
					XmlAttribute xAttr = doc.CreateAttribute(attr);
					xAttr.Value = value;
					page.Attributes.Append(xAttr);
				}
				else
				{
					page.Attributes[attr].Value = value;
				}

				// update the page
				_mApp.UpdatePageContent(doc.OuterXml);
			}
			catch (Exception e)
			{
				throw new ApplicationException("Error in SetPageAttribute: " + e.Message, e);
			}
		}