예제 #1
0
        public string GetNodeValue(IXMLDOMNode xnodCurrentNode, string sNodename, bool bHasNext)
        {
            try
            {
                string sValue = null;

                if (xnodCurrentNode == null)
                {
                    throw new Exception("xnodCurrentNode == null");
                }

                IXMLDOMNode xnodSelected = xnodCurrentNode.selectSingleNode(sNodename);
                if (xnodSelected != null)
                {
                    sValue = xnodSelected.text;

                    xnodSelected = xnodSelected.nextSibling;

                    if (xnodSelected != null)
                    {
                        bHasNext = true;
                    }

                    return(sValue);
                }

                return(null);
            }
            catch
            {
                throw;
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// Move the group down
        /// </summary>
        /// <param name="e"></param>
        private void MoveDown(DocActionEvent e)
        {
            IXMLDOMNode currentRow = e.Source;
            IXMLDOMNode rows       = currentRow.parentNode;
            IXMLDOMNode nextRow    = currentRow.selectSingleNode("following-sibling::" + currentRow.nodeName);

            rows.insertBefore(nextRow, currentRow);
        }
예제 #3
0
        /// Move the group up
        /// </summary>
        /// <param name="e"></param>
        private void MoveUp(DocActionEvent e)
        {
            IXMLDOMNode currentRow  = e.Source;
            IXMLDOMNode rows        = currentRow.parentNode;
            IXMLDOMNode previousRow = currentRow.selectSingleNode("preceding-sibling::" + currentRow.nodeName + "[1]");

            rows.insertBefore(currentRow, previousRow);
        }
예제 #4
0
        /// <summary>
        /// Insert phrase to the selected rich text box
        /// </summary>
        /// <param name="targetNode"></param>
        /// <param name="phraseID"></param>
        /// <param name="phraseDoc"></param>
        public static void InsertPhrase(IXMLDOMNode targetNode, string phraseID)
        {
            //1. Add an empty line
            //Phrase can only be inserted into rich text box
            //If the node is not rich text box node, an exception will be thrown
            //There is no way to tell whether a node is rich text box (work around, try error)
            try
            {
                //<div xmlns="http://www.w3.org/1999/xhtml"></div>
                IXMLDOMNode emptyline = targetNode.ownerDocument.createNode(1, "div", "http://www.w3.org/1999/xhtml");
                targetNode.appendChild(emptyline);
            }
            catch (Exception)
            {
                //Ignore the error,
                throw new Exception("Standard text can only be inserted into rich text box");
            }

            //Remove data from the target node
            targetNode.text = "";
            //2. Add the phrase to the selected rich text box
            // Example phrase entry, it is in the phrase xml file:
            //<Phrase ID="Text3">
            //		<Title>End quiz</Title>
            //		<Text><div xmlns="http://www.w3.org/1999/xhtml">Congratulation! you have completed your quiz.</div>
            //									<div xmlns="http://www.w3.org/1999/xhtml">Click the <strong>End quiz</strong> button to exit the quiz</div></Text>
            //</Phrase>

            IXMLDOMNode phrase = _PhraseDoc.selectSingleNode("//Phrase[@ID='" + phraseID + "']");
            IXMLDOMNode text   = phrase.selectSingleNode("Text");

            //Add all child nodes
            foreach (IXMLDOMNode child in text.childNodes)
            {
                targetNode.appendChild(child.cloneNode(true));
            }
        }
예제 #5
0
        public IXMLDOMNode GetNode(IXMLDOMNode xnodCurrentNode, string sNodename)
        {
            try
            {
                if (xnodCurrentNode != null)
                {
                    IXMLDOMNode xnodSelected = xnodCurrentNode.selectSingleNode(sNodename);
                    if (xnodSelected != null)
                    {
                        return(xnodSelected);
                    }
                }
                else
                {
                    throw new Exception("XMLParser : CurrentNode is null");
                }
            }
            catch
            {
                throw;
            }

            return(null);
        }