private static async Task<EpubNavigationLabel> ReadNavigationLabelAsync(XmlReader reader) { EpubNavigationLabel result = new EpubNavigationLabel(); var navigationLabelText = string.Empty; //We have to read to <text> subnode of the navLabel node do { if ((reader.LocalName.ToLowerInvariant() == "text") && (reader.NodeType == XmlNodeType.Element)) { navigationLabelText = reader.ReadElementContentAsString(); } } while (await reader.ReadAsync() && !(reader.NodeType == XmlNodeType.EndElement && reader.LocalName.ToLowerInvariant() == "navlabel")); if (string.IsNullOrEmpty(navigationLabelText)) throw new Exception("Incorrect EPUB navigation label: label text element is missing"); result.Text = navigationLabelText; return result; }
private static EpubNavigationLabel ReadNavigationLabel(XmlNode navigationLabelNode) { EpubNavigationLabel result = new EpubNavigationLabel(); XmlNode navigationLabelTextNode = navigationLabelNode.ChildNodes.OfType<XmlNode>(). Where(node => String.Compare(node.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0).FirstOrDefault(); if (navigationLabelTextNode == null) throw new Exception("Incorrect EPUB navigation label: label text element is missing"); result.Text = navigationLabelTextNode.InnerText; return result; }