AppendChild() public method

Adds the specified node to the end of the list of children of this node.
public AppendChild ( HtmlNode newChild ) : HtmlNode
newChild HtmlNode The node to add. May not be null.
return HtmlNode
 private static void AddContentRegions(Dictionary<string, HtmlNode> contentNodes, HtmlNode bodyNode)
 {
     foreach (var contentNode in contentNodes)
     {
         var titleNode = CreateContentTitleNode(contentNode);
         var linkNode = CreateContentLinkNode(titleNode);
         var headerNode = CreateContentHeaderNode(linkNode);
         bodyNode.AppendChild(headerNode);
     }
 }
Example #2
0
 public void AddImageNode(HtmlDocument htmlDoc,HtmlNode new_node,string image_source)
 {
     //<img src=\"{1}\" style=\"height:100%;width:100%;\"/>
     HtmlNode image_node = htmlDoc.CreateElement("img");
     HtmlAttribute src_attr = htmlDoc.CreateAttribute("src", image_source);
     image_node.Attributes.Append(src_attr);
     HtmlAttribute style_attr = htmlDoc.CreateAttribute("style", "height:100%;width:100%;");
     image_node.Attributes.Append(style_attr);
     new_node.AppendChild(image_node);
 }
Example #3
0
        public HtmlNode CloneNode(bool deep)
        {
            HtmlNode node = this._ownerdocument.CreateNode(this._nodetype);

            node.Name = this.Name;
            switch (this._nodetype)
            {
            case HtmlNodeType.Comment:
                ((HtmlCommentNode)node).Comment = ((HtmlCommentNode)this).Comment;
                return(node);

            case HtmlNodeType.Text:
                ((HtmlTextNode)node).Text = ((HtmlTextNode)this).Text;
                return(node);

            default:
                if (this.HasAttributes)
                {
                    foreach (HtmlAttribute attribute in (IEnumerable <HtmlAttribute>) this._attributes)
                    {
                        HtmlAttribute newAttribute = attribute.Clone();
                        node.Attributes.Append(newAttribute);
                    }
                }

                if (this.HasClosingAttributes)
                {
                    node._endnode = this._endnode.CloneNode(false);
                    foreach (HtmlAttribute attribute in (IEnumerable <HtmlAttribute>) this._endnode._attributes)
                    {
                        HtmlAttribute newAttribute = attribute.Clone();
                        node._endnode._attributes.Append(newAttribute);
                    }
                }

                if (!deep || !this.HasChildNodes)
                {
                    return(node);
                }
                foreach (HtmlNode childnode in (IEnumerable <HtmlNode>) this._childnodes)
                {
                    HtmlNode newChild = childnode.Clone();
                    node.AppendChild(newChild);
                }

                return(node);
            }
        }
Example #4
0
        private static HtmlNode CreateElement(HtmlNode node, string elementName, params Action <HtmlNode>[] innerNodes)
        {
            var child = node.OwnerDocument.CreateElement(elementName);

            foreach (var action in innerNodes)
            {
                if (action != null)
                {
                    action(child);
                }
            }

            node.AppendChild(child);

            return(child);
        }
Example #5
0
        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            var document = node.OwnerDocument;
            var gridContainer = document.CreateElement("div");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock
            if (style != null)
                gridContainer.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(gridContainer);

            // IMPORTANT: Unless you know better, always call this at the end. Otherwise the Content of this
            // node will NOT be turned into HTML.
            base.TransformHtml(generator, element, gridContainer);
        }
Example #6
0
        public HtmlNode CloneNode(bool deep)
        {
            HtmlNode node = _ownerdocument.CreateNode(_nodetype);

            node.Name = Name;
            switch (_nodetype)
            {
            case HtmlNodeType.Comment:
                ((HtmlCommentNode)node).Comment = ((HtmlCommentNode)this).Comment;
                return(node);

            case HtmlNodeType.Text:
                ((HtmlTextNode)node).Text = ((HtmlTextNode)this).Text;
                return(node);
            }
            if (HasAttributes)
            {
                foreach (HtmlAttribute attribute in (IEnumerable <HtmlAttribute>)_attributes)
                {
                    HtmlAttribute newAttribute = attribute.Clone();
                    node.Attributes.Append(newAttribute);
                }
            }
            if (HasClosingAttributes)
            {
                node._endnode = _endnode.CloneNode(false);
                foreach (HtmlAttribute attribute3 in (IEnumerable <HtmlAttribute>)_endnode._attributes)
                {
                    HtmlAttribute attribute4 = attribute3.Clone();
                    node._endnode._attributes.Append(attribute4);
                }
            }
            if (deep)
            {
                if (!HasChildNodes)
                {
                    return(node);
                }
                foreach (HtmlNode node2 in (IEnumerable <HtmlNode>)_childnodes)
                {
                    HtmlNode newChild = node2.Clone();
                    node.AppendChild(newChild);
                }
            }
            return(node);
        }
        public static HtmlNode CreateNode(
            HtmlDocument document,
            string name,
            string className = null,
            HtmlNode parentNode = null)
        {
            var node = document.CreateElement(name);

            if (!string.IsNullOrWhiteSpace(className))
            {
                node.SetAttributeValue("class", className);
            }

            if (parentNode != null)
            {
                parentNode.AppendChild(node);
            }

            return node;
        }
        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            var document = node.OwnerDocument;
            var buttonContainer = document.CreateElement("a");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock
            if (style != null)
                buttonContainer.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(buttonContainer);

            // For now we'll just add "Hello world" if a Button contains no content.
            if (((Button)element).Text == null)
                buttonContainer.AppendChild(document.CreateTextNode("Browse"));

            // IMPORTANT: Unless you know better, always call this at the end. Otherwise the Content of this
            // node will NOT be turned into HTML.
            base.TransformHtml(generator, element, buttonContainer);
        }
        public override void TransformHtml(Generator generator, Drawable element, HtmlNode node)
        {
            // TODO: Flesh this out. Rather bare bones at the moment.
            var document = node.OwnerDocument;
            var newElement = document.CreateElement("div");
            var style = element.Style;

            // TODO: Move this to GeneratorBlock, or not, at least not for this GeneratorBlock impl.
            // Reason being is that I do some ContentProperty voodoo, which isnt appropriate for us here.
            if (style != null)
                newElement.Attributes.Add(document.CreateAttribute("class", style));

            // Add our created element to the parent.
            node.AppendChild(newElement);

            // This is where special handling of Content comes in. I simply loop through the StackPanel and call generate.
            // TODO: Try to generalize this and move it to GeneratorBlock. Will clean things up a bit.
            foreach (var child in ((StackPanel)element).Children)
            {
                generator.Generate(newElement, child);
            }
        }
        private void Parse()
        {
            int lastquote = 0;
            if (OptionComputeChecksum)
            {
                _crc32 = new Crc32();
            }

            Lastnodes = new Dictionary<string, HtmlNode>();
            _c = 0;
            _fullcomment = false;
            _parseerrors = new List<HtmlParseError>();
            _line = 1;
            _lineposition = 1;
            _maxlineposition = 1;

            _state = ParseState.Text;
            _oldstate = _state;
            _documentnode._innerlength = Text.Length;
            _documentnode._outerlength = Text.Length;
            _remainderOffset = Text.Length;

            _lastparentnode = _documentnode;
            _currentnode = CreateNode(HtmlNodeType.Text, 0);
            _currentattribute = null;

            _index = 0;
            PushNodeStart(HtmlNodeType.Text, 0);
            while (_index < Text.Length)
            {
                _c = Text[_index];
                IncrementPosition();

                switch (_state)
                {
                    case ParseState.Text:
                        if (NewCheck())
                            continue;
                        break;

                    case ParseState.WhichTag:
                        if (NewCheck())
                            continue;
                        if (_c == '/')
                        {
                            PushNodeNameStart(false, _index);
                        }
                        else
                        {
                            PushNodeNameStart(true, _index - 1);
                            DecrementPosition();
                        }
                        _state = ParseState.Tag;
                        break;

                    case ParseState.Tag:
                        if (NewCheck())
                            continue;
                        if (IsWhiteSpace(_c))
                        {
                            PushNodeNameEnd(_index - 1);
                            if (_state != ParseState.Tag)
                                continue;
                            _state = ParseState.BetweenAttributes;
                            continue;
                        }
                        if (_c == '/')
                        {
                            PushNodeNameEnd(_index - 1);
                            if (_state != ParseState.Tag)
                                continue;
                            _state = ParseState.EmptyTag;
                            continue;
                        }
                        if (_c == '>')
                        {
                            PushNodeNameEnd(_index - 1);
                            if (_state != ParseState.Tag)
                                continue;
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            if (_state != ParseState.Tag)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                        }
                        break;

                    case ParseState.BetweenAttributes:
                        if (NewCheck())
                            continue;

                        if (IsWhiteSpace(_c))
                            continue;

                        if ((_c == '/') || (_c == '?'))
                        {
                            _state = ParseState.EmptyTag;
                            continue;
                        }

                        if (_c == '>')
                        {
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }

                            if (_state != ParseState.BetweenAttributes)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }

                        PushAttributeNameStart(_index - 1);
                        _state = ParseState.AttributeName;
                        break;

                    case ParseState.EmptyTag:
                        if (NewCheck())
                            continue;

                        if (_c == '>')
                        {
                            if (!PushNodeEnd(_index, true))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }

                            if (_state != ParseState.EmptyTag)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        _state = ParseState.BetweenAttributes;
                        break;

                    case ParseState.AttributeName:
                        if (NewCheck())
                            continue;

                        if (IsWhiteSpace(_c))
                        {
                            PushAttributeNameEnd(_index - 1);
                            _state = ParseState.AttributeBeforeEquals;
                            continue;
                        }
                        if (_c == '=')
                        {
                            PushAttributeNameEnd(_index - 1);
                            _state = ParseState.AttributeAfterEquals;
                            continue;
                        }
                        if (_c == '>')
                        {
                            PushAttributeNameEnd(_index - 1);
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            if (_state != ParseState.AttributeName)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        break;

                    case ParseState.AttributeBeforeEquals:
                        if (NewCheck())
                            continue;

                        if (IsWhiteSpace(_c))
                            continue;
                        if (_c == '>')
                        {
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            if (_state != ParseState.AttributeBeforeEquals)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        if (_c == '=')
                        {
                            _state = ParseState.AttributeAfterEquals;
                            continue;
                        }
                        // no equals, no whitespace, it's a new attrribute starting
                        _state = ParseState.BetweenAttributes;
                        DecrementPosition();
                        break;

                    case ParseState.AttributeAfterEquals:
                        if (NewCheck())
                            continue;

                        if (IsWhiteSpace(_c))
                            continue;

                        if ((_c == '\'') || (_c == '"'))
                        {
                            _state = ParseState.QuotedAttributeValue;
                            PushAttributeValueStart(_index, _c);
                            lastquote = _c;
                            continue;
                        }
                        if (_c == '>')
                        {
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            if (_state != ParseState.AttributeAfterEquals)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        PushAttributeValueStart(_index - 1);
                        _state = ParseState.AttributeValue;
                        break;

                    case ParseState.AttributeValue:
                        if (NewCheck())
                            continue;

                        if (IsWhiteSpace(_c))
                        {
                            PushAttributeValueEnd(_index - 1);
                            _state = ParseState.BetweenAttributes;
                            continue;
                        }

                        if (_c == '>')
                        {
                            PushAttributeValueEnd(_index - 1);
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            if (_state != ParseState.AttributeValue)
                                continue;
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        break;

                    case ParseState.QuotedAttributeValue:
                        if (_c == lastquote)
                        {
                            PushAttributeValueEnd(_index - 1);
                            _state = ParseState.BetweenAttributes;
                            continue;
                        }
                        if (_c == '<')
                        {
                            if (_index < Text.Length)
                            {
                                if (Text[_index] == '%')
                                {
                                    _oldstate = _state;
                                    _state = ParseState.ServerSideCode;
                                    continue;
                                }
                            }
                        }
                        break;

                    case ParseState.Comment:
                        if (_c == '>')
                        {
                            if (_fullcomment)
                            {
                                if ((Text[_index - 2] != '-') ||
                                    (Text[_index - 3] != '-'))
                                {
                                    continue;
                                }
                            }
                            if (!PushNodeEnd(_index, false))
                            {
                                // stop parsing
                                _index = Text.Length;
                                break;
                            }
                            _state = ParseState.Text;
                            PushNodeStart(HtmlNodeType.Text, _index);
                            continue;
                        }
                        break;

                    case ParseState.ServerSideCode:
                        if (_c == '%')
                        {
                            if (_index < Text.Length)
                            {
                                if (Text[_index] == '>')
                                {
                                    switch (_oldstate)
                                    {
                                        case ParseState.AttributeAfterEquals:
                                            _state = ParseState.AttributeValue;
                                            break;

                                        case ParseState.BetweenAttributes:
                                            PushAttributeNameEnd(_index + 1);
                                            _state = ParseState.BetweenAttributes;
                                            break;

                                        default:
                                            _state = _oldstate;
                                            break;
                                    }
                                    IncrementPosition();
                                }
                            }
                        }
                        break;

                    case ParseState.PcData:
                        // look for </tag + 1 char

                        // check buffer end
                        if ((_currentnode._namelength + 3) <= (Text.Length - (_index - 1)))
                        {
                            if (string.Compare(Text.Substring(_index - 1, _currentnode._namelength + 2),
                                               "</" + _currentnode.Name, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                int c = Text[_index - 1 + 2 + _currentnode.Name.Length];
                                if ((c == '>') || (IsWhiteSpace(c)))
                                {
                                    // add the script as a text node
                                    HtmlNode script = CreateNode(HtmlNodeType.Text,
                                                                 _currentnode._outerstartindex +
                                                                 _currentnode._outerlength);
                                    script._outerlength = _index - 1 - script._outerstartindex;
                                    _currentnode.AppendChild(script);

                                    PushNodeStart(HtmlNodeType.Element, _index - 1);
                                    PushNodeNameStart(false, _index - 1 + 2);
                                    _state = ParseState.Tag;
                                    IncrementPosition();
                                }
                            }
                        }
                        break;
                }
            }

            // finish the current work
            if (_currentnode._namestartindex > 0)
            {
                PushNodeNameEnd(_index);
            }
            PushNodeEnd(_index, false);

            // we don't need this anymore
            Lastnodes.Clear();
        }
Example #11
0
 HtmlNode GetStrippedForm(HtmlNode OriginalForm, List<string> InputElementStrings)
 {
     OriginalForm.RemoveAllChildren();
     foreach (string InputElementString in InputElementStrings)
     {
         HTML InputHtml = new HTML(InputElementString);
         OriginalForm.AppendChild(InputHtml.Html.DocumentNode.FirstChild);
     }
     return OriginalForm;
 }
Example #12
0
        /// <summary>
        /// Traverse the directory structure present in provided DirectoryModel and
        /// create HTML that will represent the directories and files that are found.
        /// </summary>
        /// <param name="directory">Directory containing subdirectories and articles.</param>
        /// <param name="listFileDoc">Object representing HTML document.</param>
        /// <param name="directoryDiv">Container representing div that will contain categories and articles.</param>
        /// <param name="isSourceDir">Bool representing whether directoryDiv, is parent directory of article directory structure.</param>
        static void GenerateHTML(DirectoryModel directory, HtmlDocument listFileDoc, HtmlNode directoryContainerDiv, 
            bool isSourceDir, ref int index, string categoriesUrlText)
        {
            // Hash directory path to be used as unique identifier for
            // folder div's id attribute
            index++;
            string encryptedPath = EncryptStrings.EncryptToMD5String(directory.Path);

            // Create div that will hold folder icon and directory name
            HtmlNode directoryDiv = listFileDoc.CreateElement("div");

            // Container for categories (subdirectories) and article links.
            directoryDiv.SetAttributeValue("class", "directory");
            directoryDiv.SetAttributeValue("id", encryptedPath);

            // Check whether or not current directory, is the parent node
            // of article directory structure (as this is first container to be seen)
            string style = isSourceDir ? String.Format("z-index: {0};", index) : String.Format("z-index: -{0}; display: none", index);
            directoryDiv.SetAttributeValue("style", style);

            // div to hold category header and links to roll back to previous views
            HtmlNode directoryCategoryContainer = listFileDoc.CreateElement("div");
            directoryCategoryContainer.SetAttributeValue("id", "category-container");

            // header for category section of directory div
            HtmlNode directoryHeader = listFileDoc.CreateElement("h2");
            directoryHeader.SetAttributeValue("class", "category-headers");

            // add text node for header
            HtmlNode categoryHeaderText = listFileDoc.CreateTextNode("Categories");
            directoryHeader.AppendChild(categoryHeaderText);
            directoryCategoryContainer.AppendChild(directoryHeader);

            // create div to hold category urls used to roll back to a
            //previous view
            HtmlNode categoryUrlDiv = listFileDoc.CreateElement("div");
            categoryUrlDiv.SetAttributeValue("class", "visited-categories-container");

            // add category url text
            HtmlNode categoryUrlText = listFileDoc.CreateTextNode(categoriesUrlText);
            categoryUrlDiv.AppendChild(categoryUrlText);
            directoryCategoryContainer.AppendChild(categoryUrlDiv);

            // add container for category header and links for rolling back to particular views
            // to the directory container div
            directoryDiv.AppendChild(directoryCategoryContainer);

            HtmlNode categoryRule = listFileDoc.CreateElement("hr");
            categoryRule.SetAttributeValue("class", "header-rule");
            directoryDiv.AppendChild(categoryRule);

            // update current url string to be used by subordinate categories
            string currentUrlName = Path.GetFileName(directory.Path);

            if (categoriesUrlText == String.Empty)
            {
                categoriesUrlText += @"<a href='#' onclick='rollBack("""")'>Home</a>";
            }
            else
            {
                categoriesUrlText += @" > <a href='#' onclick='rollBack(""" + encryptedPath + @""")'>" +
                                    currentUrlName + "</a>";
            }

            // Process subdirectories' contents and generate relevant
            // html.
            if (directory.Subdirectories.Count > 0)
            {
                foreach (DirectoryModel subdirectory in directory.Subdirectories)
                {
                    isSourceDir = false;

                    HtmlNode subDirectoryDiv = listFileDoc.CreateElement("div");
                    subDirectoryDiv.SetAttributeValue("class", "subdirectory");
                    subDirectoryDiv.SetAttributeValue("name", EncryptStrings.EncryptToMD5String(subdirectory.Path));
                    subDirectoryDiv.SetAttributeValue("onclick", "bringToFront(this)");

                    HtmlNode folderParagraph = listFileDoc.CreateElement("p");
                    folderParagraph.SetAttributeValue("class", "folder-name");

                    HtmlTextNode text = listFileDoc.CreateTextNode(Path.GetFileName(subdirectory.Path));
                    folderParagraph.AppendChild(text);

                    subDirectoryDiv.AppendChild(folderParagraph);

                    directoryDiv.AppendChild(subDirectoryDiv);

                    GenerateHTML(subdirectory, listFileDoc, directoryContainerDiv, isSourceDir, ref index, categoriesUrlText);
                }
            }

            // Container for links to show articles.
            HtmlNode clearFloatDiv = listFileDoc.CreateElement("div");
            clearFloatDiv.SetAttributeValue("style", "clear: both; width: 100%;");
            directoryDiv.AppendChild(clearFloatDiv);

            HtmlNode articleHeader = listFileDoc.CreateElement("h2");
            articleHeader.SetAttributeValue("class", "article-headers");

            HtmlNode articleHeaderText = listFileDoc.CreateTextNode("Articles");
            articleHeader.AppendChild(articleHeaderText);
            directoryDiv.AppendChild(articleHeader);

            HtmlNode articleRule = listFileDoc.CreateElement("hr");
            articleRule.SetAttributeValue("class", "header-rule");
            directoryDiv.AppendChild(articleRule);

            // Check that html files exist in directory and create representative
            // html links.
            if (directory.Files.Keys.Count > 0)
            {
                HtmlNode linkContainerNode = listFileDoc.CreateElement("ul");
                linkContainerNode.SetAttributeValue("class", "article-list");

                foreach (string key in directory.Files.Keys)
                {
                    HtmlNode listNode = listFileDoc.CreateElement("li");

                    HtmlNode linkNode = listFileDoc.CreateElement("a");

                    HtmlTextNode textNode = listFileDoc.CreateTextNode(directory.Files[key]);
                    linkNode.AppendChild(textNode);

                    string file = key;

                    linkNode.SetAttributeValue("id", EncryptStrings.EncryptToAESString(file));
                    linkNode.SetAttributeValue("href", "#");
                    linkNode.SetAttributeValue("onclick", "setContent(this.id)");

                    listNode.AppendChild(linkNode);

                    linkContainerNode.AppendChild(listNode);
                }

                directoryDiv.AppendChild(linkContainerNode);
            }

            directoryContainerDiv.AppendChild(directoryDiv);
        }
        private void WriteLittleDocument(KeyValuePair<string, HtmlNode> contentNode, HtmlNode bodyNode)
        {
            bodyNode.AppendChild(contentNode.Value);
            string htmlText = GetHtmlText();

            var htmlBytes = Encoding.Default.GetBytes(htmlText);
            using (var stream = File.Create(contentNode.Key + ".html"))
            {
                stream.Write(htmlBytes, 0, htmlBytes.Length);
            }
            contentNode.Value.Remove();
        }
Example #14
0
        /// <summary>
        /// Replaces all child nodes with the supplied nodes and indents them +1 tab.
        /// </summary>
        private void ReplaceAllChildren(HtmlNode parent, IEnumerable<HtmlNode> nodes)
        {
            // Preserve the indentation of the parent.
            var parentScope = CreateTextNode();
            var prev = parent.PreviousSibling;
            if (prev == null && parent.ParentNode != null)
                prev = parent.ParentNode.PreviousSibling;
            if (prev != null && prev.NodeType == HtmlNodeType.Text)
            {
                var m = TabsAndSpaces.Match(prev.InnerText);
                if (m.Success)
                    parentScope.InnerHtml += m.Value;
            }

            // Add one tab of indentation for the children.
            var childScope = CreateTextNode(parentScope.InnerText + "\t");

            // Replace all children with supplied nodes (indented).
            parent.RemoveAllChildren();
            foreach (var option in nodes)
            {
                parent.AppendChild(childScope);
                parent.AppendChild(option);
            }

            // Put the closing tag at the same indentation as the opening tag.
            parent.AppendChild(parentScope);
        }
        public void PopulateIssueInfoNode(HtmlNode issueInfoNode, HtmlNode kesiNode, HtmlNode mdNode)
        {
            string status = GetNodeInnerText(kesiNode, "./s:issueStatus", null);
            if (status != null)
                issueInfoNode.SetAttributeValue("status", status.EncodeXMLString());
            string resolution = GetNodeInnerText(kesiNode, "./s:issueResolution", null);
            if (resolution != null)
                issueInfoNode.SetAttributeValue("resolution", resolution.EncodeXMLString());
            string productName = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productId", null);
            if (productName != null && GetNodeInnerText(kesiNode, "./s:issueActivity/s:activityWhat", "Product") == "Product")
                issueInfoNode.SetAttributeValue("productName", productName.EncodeXMLString());
            string componentName = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productComponentId", null);
            if (componentName != null && GetNodeInnerText(kesiNode, "./s:issueActivity/s:activityWhat", "Component") == "Component")
                issueInfoNode.SetAttributeValue("componentName", componentName.EncodeXMLString());

            string priority = GetNodeInnerText(kesiNode, "./s:issuePriority", null);
            if (priority != null)
                issueInfoNode.SetAttributeValue("priority", priority.EncodeXMLString());
            string severity = GetNodeInnerText(kesiNode, "./s:issueSeverity", null);
            if (severity != null)
                issueInfoNode.SetAttributeValue("severity", severity.EncodeXMLString());

            string systemOS = GetNodeInnerText(kesiNode, "./s:issueComputerSystem/s:computerSystemOS", null);
            if (systemOS != null)
                issueInfoNode.SetAttributeValue("systemOS", systemOS.EncodeXMLString());
            string systemPlatform = GetNodeInnerText(kesiNode, "./s:issueComputerSystem/s:computerSystemPlatform", null);
            if (systemPlatform != null)
                issueInfoNode.SetAttributeValue("systemPlatform", systemPlatform.EncodeXMLString());
            string productVersion = GetNodeInnerText(kesiNode, "./s:issueProduct/s:productVersion", null);
            if (productVersion != null)
                issueInfoNode.SetAttributeValue("productVersion", productVersion.EncodeXMLString());

            string assignedToName = GetIssueAssignedTo(kesiNode);
            string assignedToUri = GetNodeInnerText(mdNode, "./o:issueAssignedToUri", null);
            if (!string.IsNullOrEmpty(assignedToName)) {
                HtmlNode assignedToNode = issueInfoNode.OwnerDocument.CreateElement("assignedTo");
                issueInfoNode.AppendChild(assignedToNode);
                assignedToNode.SetAttributeValue("name", assignedToName.EncodeXMLString());
                if (!string.IsNullOrEmpty(assignedToUri))
                    assignedToNode.SetAttributeValue("uri", assignedToUri.EncodeXMLString());
            }
            string CCName = GetIssueCCPerson(kesiNode);
            string CCUri = GetNodeInnerText(mdNode, "./o:issueCCPerson", null);		// todo: change this to the right value
            if (!string.IsNullOrEmpty(CCName)) {
                HtmlNode assignedToNode = issueInfoNode.OwnerDocument.CreateElement("CC");
                issueInfoNode.AppendChild(assignedToNode);
                assignedToNode.SetAttributeValue("name", CCName.EncodeXMLString());
                if (!string.IsNullOrEmpty(CCUri))
                    assignedToNode.SetAttributeValue("uri", CCUri.EncodeXMLString());
            }
        }
Example #16
0
 void CopyInputElementsIntoForm(HtmlNode SourceForm, HtmlNode DestinationForm)
 {
     foreach (HtmlNode Node in SourceForm.ChildNodes)
     {
         if (Node.Name.Equals("input"))
         {
             DestinationForm.AppendChild(CopyNodeTopElement(Node, DestinationForm.OwnerDocument));
         }
         else if (Node.ChildNodes.Count > 0)
         {
             CopyInputElementsIntoForm(Node, DestinationForm);
         }
     }
 }
Example #17
0
 public static HtmlNode AppendNonBreakingSpace(this HtmlNode node)
 {
     return(node.AppendChild(node.OwnerDocument.CreateTextNode("&nbsp;")));
 }
Example #18
0
 public static HtmlNode AppendNonBreakingHyphen(this HtmlNode node)
 {
     return(node.AppendChild(node.OwnerDocument.CreateTextNode("&#8209;")));
 }
 void AddReferences(HtmlNode node, string elementTitle, HashSet<string> references)
 {
     if (node == null)
         return;
     HtmlNode referencesNode = node.OwnerDocument.CreateElement(elementTitle);
     foreach (string reference in references)
         referencesNode.AppendChild(CreateNodeWithTextContent(node.OwnerDocument, "s1:referenceUri", reference));
     node.AppendChild(referencesNode);
 }
        void AddAnnotatedText(HtmlNode node, string elementTitle, string annotatedData, bool putInCDataBlock = true)
        {
            if (node == null)
                return;
            XmlDocument doc = (XmlDocument)node.OwnerDocument;

            HtmlNode annotatedNode;
            if (putInCDataBlock)
                annotatedNode = doc.CreateCDataElementInsideWrapperNode(elementTitle, annotatedData);
            else
                annotatedNode = CreateNodeWithTextContent(doc, elementTitle, annotatedData.EncodeXMLString());
            //annotatedNode.Name = elementTitle;
            node.AppendChild(annotatedNode);
        }
 void AddAnnotatedConcepts(HtmlNode node, string elementTitle, Dictionary<string, double> conceptToWeight)
 {
     if (node == null)
         return;
     HtmlNode conceptsNode = node.OwnerDocument.CreateElement(elementTitle);
     foreach (var concept in conceptToWeight)
     {
         HtmlNode conceptNode = node.OwnerDocument.CreateElement("s1:concept");
         HtmlNode uriNode = CreateNodeWithTextContent(node.OwnerDocument, "s1:uri", concept.Key.EncodeXMLString());
         string wgt = (concept.Value == (int)concept.Value) ? ((int)concept.Value).ToString() : String.Format("{0:F4}", concept.Value);
         HtmlNode weightNode = CreateNodeWithTextContent(node.OwnerDocument, "s1:weight", wgt);
         conceptNode.AppendChild(uriNode);
         conceptNode.AppendChild(weightNode);
         conceptsNode.AppendChild(conceptNode);
     }
     node.AppendChild(conceptsNode);
 }
 public void AddNewLines(HtmlNode node, int numberOfTabs)
 {
     if (node == null)
         return;
     string text = Environment.NewLine;
     for (int i = 0; i < numberOfTabs; i++)
         text += "\t";
     HtmlTextNode textNode = node.OwnerDocument.CreateTextNode(text);
     node.AppendChild(textNode);
 }