Exemple #1
0
        private static HtmlNode GatherInformation(IframeInformation iframeInformation, HtmlNode currentNode, bool isGoingUp)
        {
            if (currentNode.Name.Equals("p"))
            {
                var classOfNode = currentNode.GetAttributeValue("class", string.Empty);

                if (classOfNode.Contains("exhibit-number"))
                {
                    iframeInformation.Number = currentNode.InnerText.Trim();
                }
                else if (classOfNode.Contains("exhibit-title"))
                {
                    iframeInformation.Title = currentNode.InnerText.Trim();
                }
                else if (classOfNode.Contains("source"))
                {
                    iframeInformation.Source = currentNode.InnerText.Trim();
                }
                else if (classOfNode.Contains("caption"))
                {
                    iframeInformation.Caption = currentNode.InnerText.Trim();
                }
            }
            return(isGoingUp ? currentNode.PreviousSibling : currentNode.NextSibling);
        }
Exemple #2
0
        private static IframeInformation GetIframeInformation(HtmlNode node)
        {
            var iframeInformation = new IframeInformation();

            if (node.HasAttributes)
            {
                var currentNode = node.PreviousSibling;
//extract header and title from the HTML in sitecore
                for (int i = 0; i < MaximumNodeRangeUpward; i++)
                {
                    if (currentNode == null)
                    {
                        continue;
                    }
                    currentNode = currentNode.PreviousSibling;
                    if (currentNode.HasAttributes)
                    {
                        var classOfNode = currentNode.GetAttributeValue("class", string.Empty);
                        if (classOfNode.Contains("exhibit-number") || classOfNode.Contains("exhibit-title") ||
                            classOfNode.Contains("source") || classOfNode.Contains("caption"))
                        {
                            currentNode = GatherInformation(iframeInformation, currentNode, true);
                        }
                    }
                }

//extract source and caption from the HTML in sitecore
                if (node.NextSibling != null)
                {
                    currentNode = node.NextSibling;
                    for (int i = 0; i < MaximumNodeRangedownward; i++)
                    {
                        if (currentNode != null && currentNode.NextSibling != null)
                        {
                            currentNode = currentNode.NextSibling;
                            if (currentNode.HasAttributes)
                            {
                                var classOfNode = currentNode.GetAttributeValue("class", string.Empty);
                                if (classOfNode.Contains("exhibit-number") || classOfNode.Contains("exhibit-title") ||
                                    classOfNode.Contains("source") || classOfNode.Contains("caption"))
                                {
                                    currentNode = GatherInformation(iframeInformation, currentNode, false);
                                }
                            }
                        }
                    }
                }
            }

            return(iframeInformation);
        }