CreateXmlElement() public method

public CreateXmlElement ( XmlDocument xmldoc, string elementName ) : XmlElement
xmldoc System.Xml.XmlDocument
elementName string
return System.Xml.XmlElement
Esempio n. 1
0
        // Add one symbol name.
        private void AddOneSymbolName(string symbolId, SymbolText symbolText)
        {
            symbolText.Plural = false;
            symbolText.Gender = "";

            // Find existing symbol, for this symbolId. Could be more than one for ones that have different ones for different standards.
            XmlNodeList symbolNodes = root.SelectNodes(string.Format("/symbols/symbol[@id='{0}']", symbolId));

            foreach (XmlNode symbolNode in symbolNodes)
            {
                // The new node to insert/replace.
                XmlNode newNode = symbolText.CreateXmlElement(xmldoc, "name");

                // Add new name node
                symbolNode.PrependChild(newNode);
                symbolNode.InsertBefore(xmldoc.CreateTextNode("\r\n\t\t"), newNode);
            }
        }
Esempio n. 2
0
        // Add one description text.
        private void AddOneDescriptionText(string symbolId, SymbolText symbolText)
        {
            // Find existing symbol, for this symbolId. Could be more than one for ones that have different ones for different standards.
            XmlNodeList symbolNodes = root.SelectNodes(string.Format("/symbols/symbol[@id='{0}']", symbolId));

            foreach (XmlNode symbolNode in symbolNodes)
            {
                // The new node to insert/replace.
                XmlNode newNode = symbolText.CreateXmlElement(xmldoc, "text");

                // Find existing name node, for this symbolId
                XmlNodeList nameNodeList = symbolNode.SelectNodes("name");
                XmlNode     lastNameNode = nameNodeList[nameNodeList.Count - 1];

                // Add new text node
                XmlNode parent = lastNameNode.ParentNode;
                parent.InsertAfter(newNode, lastNameNode);
                parent.InsertBefore(xmldoc.CreateTextNode("\r\n\t\t"), newNode);
            }
        }
        // Add one symbol name.
        private void AddOneSymbolName(string symbolId, SymbolText symbolText)
        {
            symbolText.Plural = false;
               symbolText.Gender = "";

            // The new node to insert/replace.
            XmlNode newNode = symbolText.CreateXmlElement(xmldoc, "name");

            // Find existing symbol, for this symbolId
            XmlNode symbolNode = root.SelectSingleNode(string.Format("/symbols/symbol[@id='{0}']", symbolId));

            // Add new name node
            symbolNode.PrependChild(newNode);
            symbolNode.InsertBefore(xmldoc.CreateTextNode("\r\n\t\t"), newNode);
        }
        // Add one description text.
        private void AddOneDescriptionText(string symbolId, SymbolText symbolText)
        {
            // The new node to insert/replace.
            XmlNode newNode = symbolText.CreateXmlElement(xmldoc, "text");

            // Find existing name node, for this symbolId
            XmlNodeList nameNodeList = root.SelectNodes(string.Format("/symbols/symbol[@id='{0}']/name", symbolId));
            XmlNode lastNameNode = nameNodeList[nameNodeList.Count - 1];

            // Add new text node
            XmlNode parent = lastNameNode.ParentNode;
            parent.InsertAfter(newNode, lastNameNode);
            parent.InsertBefore(xmldoc.CreateTextNode("\r\n\t\t"), newNode);
        }