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

GetPageAttribute() public method

Gets the value of an attribute of the page
public GetPageAttribute ( string pageId, string attr ) : string
pageId string ID of the page
attr string the attribute of interest
return string
		public string GetPageAttribute(string pageId, string attr)
		{
			try
			{
				string hierarchy;
				string sectionId;
				_mApp.GetHierarchyParent(pageId, out sectionId);
				_mApp.GetHierarchy(sectionId, HierarchyScope.hsPages, out hierarchy);

				var doc = new XmlDocument();
				doc.LoadXml(hierarchy);

				string xpath = String.Format("//one:Page[@ID='{0}']", pageId);
				XmlNode page = doc.SelectSingleNode(xpath, GetNSManager(doc.NameTable));

				if (page == null || page.Attributes == null || page.Attributes[attr] == null) return String.Empty;

				return page.Attributes[attr].Value;
			}
			catch (Exception e)
			{
				throw new ApplicationException("Error in GetPageAttribute: " + e.Message, e);
			}
		}
		#endregion