//pass in the filename without // File: <catalogPath>\ContentStore\installedBooks.5.xml private void ReadFile_InstalledBooksXml() { String baseFilePath = Path.Combine(CatalogLocation, "ContentStore", "installedBooks.xml"); String path = FileUtility.GetFileName(baseFilePath); //Returns the actualy (latest version) filename if (!File.Exists(path)) return; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(path); XmlNode nodeInstalledBooks = xmlDoc.SelectSingleNode("//installed-books"); //root node if (nodeInstalledBooks == null) return; this._installedBooks = new InstalledBooks(); //Check version -- Should be 1.0 if (nodeInstalledBooks.Attributes["version"] != null) { _installedBooks.version = nodeInstalledBooks.Attributes["version"].InnerXml; } //<installed-books> // <branding-packages> // <brandingpackage locale="EN-US" vendorname="MICROSOFT" package="VISUALSTUDIO_2011_BRANDING_EN-US" /> // </branding-packages> //</installed-books> XmlNode nodeBrandingPackages = nodeInstalledBooks.SelectSingleNode("//branding-packages"); if (nodeBrandingPackages != null && nodeBrandingPackages.HasChildNodes) { foreach (XmlNode n in nodeBrandingPackages.ChildNodes) { if (n.Name == "brandingpackage" && n.Attributes["locale"] != null && n.Attributes["vendorname"] != null && n.Attributes["package"] != null) { _installedBooks.brandingPackages.Add(new BrandingPackage( n.Attributes["locale"].InnerXml, n.Attributes["vendorname"].InnerXml, n.Attributes["package"].InnerXml)); } } } //<installed-books version="3"> // <locale-membership> // <locale name="EN-US"> // </locale> // ... // </locale-membership> //</installed-books> XmlNode nodeLocaleMembership = nodeInstalledBooks.SelectSingleNode("//locale-membership"); if (nodeLocaleMembership == null || !nodeLocaleMembership.HasChildNodes) return; foreach (XmlNode n in nodeLocaleMembership.ChildNodes) // <locale name="EN-US">... <locale name="fr-fr"> etc { if (n.Name == "locale" && n.Attributes["name"] != null) { LocaleListItem localeItem = new LocaleListItem(n.Attributes["name"].InnerXml); _installedBooks.localeList.Add(localeItem); // Get Locale Book Lists GetBookList(localeItem, n); } } }
// File: <catalogPath>\ContentStore\installedBooks.5.xml private void ReadFile_InstalledBooksXml() //pass in the filename without { String baseFilePath = Path.Combine(CatalogLocation, "ContentStore", "installedBooks.xml"); String path = FileUtility.GetFileName(baseFilePath); //Returns the actualy (latest version) filename if (!File.Exists(path)) { return; } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(path); XmlNode nodeInstalledBooks = xmlDoc.SelectSingleNode("//installed-books"); //root node if (nodeInstalledBooks == null) { return; } this._installedBooks = new InstalledBooks(); //Check version -- Should be 1.0 if (nodeInstalledBooks.Attributes["version"] != null) { _installedBooks.version = nodeInstalledBooks.Attributes["version"].InnerXml; } //<installed-books> // <branding-packages> // <brandingpackage locale="EN-US" vendorname="MICROSOFT" package="VISUALSTUDIO_2011_BRANDING_EN-US" /> // </branding-packages> //</installed-books> XmlNode nodeBrandingPackages = nodeInstalledBooks.SelectSingleNode("//branding-packages"); if (nodeBrandingPackages != null && nodeBrandingPackages.HasChildNodes) { foreach (XmlNode n in nodeBrandingPackages.ChildNodes) { if (n.Name == "brandingpackage" && n.Attributes["locale"] != null && n.Attributes["vendorname"] != null && n.Attributes["package"] != null) { _installedBooks.brandingPackages.Add(new BrandingPackage( n.Attributes["locale"].InnerXml, n.Attributes["vendorname"].InnerXml, n.Attributes["package"].InnerXml)); } } } //<installed-books version="3"> // <locale-membership> // <locale name="EN-US"> // </locale> // ... // </locale-membership> //</installed-books> XmlNode nodeLocaleMembership = nodeInstalledBooks.SelectSingleNode("//locale-membership"); if (nodeLocaleMembership == null || !nodeLocaleMembership.HasChildNodes) { return; } foreach (XmlNode n in nodeLocaleMembership.ChildNodes) // <locale name="EN-US">... <locale name="fr-fr"> etc { if (n.Name == "locale" && n.Attributes["name"] != null) { LocaleListItem localeItem = new LocaleListItem(n.Attributes["name"].InnerXml); _installedBooks.localeList.Add(localeItem); // Get Locale Book Lists GetBookList(localeItem, n); } } }