WorkbookPublishSettings.ParseXml_GetOwnerName C# (CSharp) Method

ParseXml_GetOwnerName() static private method

Looks for the Owner Name information inside the XML document
static private ParseXml_GetOwnerName ( XmlDocument xmlDoc ) : string
xmlDoc XmlDocument
return string
    internal static string ParseXml_GetOwnerName(XmlDocument xmlDoc)
    {
        var xNodeOwner = xmlDoc.SelectSingleNode("//" + XmlElement_ContentOwner);

        //If there is no node, then return the default
        if (xNodeOwner == null)
        {
            return null;
        }

        return XmlHelper.SafeParseXmlAttribute(xNodeOwner, XmlHelper.XmlAttribute_Value, null);
    }

Usage Example

    /// <summary>
    /// Look up any saved settings we have associated with a datasource on our local file systemm
    /// </summary>
    /// <param name="datasourceWithPath"></param>
    /// <returns></returns>
    internal static DatasourcePublishSettings GetSettingsForSavedDatasource(string datasourceWithPath)
    {
        //Sanity test: If the datasource is not there, then we probably have an incorrect path
        AppDiagnostics.Assert(File.Exists(datasourceWithPath), "Underlying datasource does not exist");

        //Find the path to the settings file
        var pathToSettingsFile = PathForSettingsFile(datasourceWithPath);

        if (!File.Exists(pathToSettingsFile))
        {
            return(new DatasourcePublishSettings(null));
        }

        //===================================================================
        //We've got a setings file, let's parse it!
        //===================================================================
        var xmlDoc = new XmlDocument();

        xmlDoc.Load(pathToSettingsFile);

        //Show sheets
        string ownerName = WorkbookPublishSettings.ParseXml_GetOwnerName(xmlDoc);

        //Return the Settings data
        return(new DatasourcePublishSettings(ownerName));
    }