Пример #1
0
        private void InitXml()
        {
            // création du tag xml
            //XNode element = CreateElement("xml");
            //AddElement(_documentNode, element);
            //_currentNode = _currentTreeNode = element;
            _currentNode = _currentTreeNode = _xdCreator.AddRootElement("xml");

            // inutile car AddText() n'ajoute le texte que si ce n'est pas un séparateur
            //if (!_generateXmlNodeOnly)
            //    AddText(_currentNode, "\r\n");

            if (_normalizeXml)
            {
                // création du tag html
                //element = CreateElement("html");
                //AddElement(_currentTreeNode, element);
                //_htmlNode = _currentNode = _currentTreeNode = element;
                _htmlNode = _currentNode = _currentTreeNode = _xdCreator.AddElement(_currentTreeNode, "html");

                // inutile car AddText() n'ajoute le texte que si ce n'est pas un séparateur
                //if (!_generateXmlNodeOnly)
                //    AddText(_currentNode, "\r\n");

                // création du tag head
                //element = CreateElement("head");
                //AddElement(_currentTreeNode, element);
                //_headNode = _currentNode = element;
                _headNode = _currentNode = _xdCreator.AddElement(_currentTreeNode, "head");

                // inutile car AddText() n'ajoute le texte que si ce n'est pas un séparateur
                //if (!_generateXmlNodeOnly)
                //    AddText(_currentNode, "\r\n");

                // création du tag title
                //element = CreateElement("title");
                //AddElement(_currentNode, element);
                //_titleNode = _currentNode = element;
                _titleNode = _xdCreator.AddElement(_currentNode, "title");

                // création du tag body
                //element = CreateElement("body");
                //AddElement(_currentTreeNode, element);
                //_bodyNode = _currentNode = element;
                _bodyNode = _currentNode = _xdCreator.AddElement(_currentTreeNode, "body");

                // inutile car AddText() n'ajoute le texte que si ce n'est pas un séparateur
                //if (!_generateXmlNodeOnly)
                //    AddText(_currentNode, "\r\n");

                _currentNode = _currentTreeNode = _headNode;
            }
        }
Пример #2
0
        private void AddElement(XXXNode_v2 parent, XXXNode_v2 child)
        {
            if (parent.XmlNode != null)
            {
                parent.XmlNode.AppendChild(child.XmlNode);
            }
            XNode xnode = parent.XNode;

            if (xnode != null)
            {
                if (xnode is XElement)
                {
                    if (_xdCreator != null)
                    {
                        _xdCreator.AddElement((XElement)xnode, (XElement)child.XNode);
                    }
                    else
                    {
                        ((XElement)xnode).Add(child.XNode);
                    }
                }
                else if (xnode is XDocument)
                {
                    if (_xdCreator != null)
                    {
                        _xdCreator.AddRootElement((XElement)child.XNode);
                    }
                    else
                    {
                        ((XDocument)xnode).Add(child.XNode);
                    }
                }
                else
                {
                    throw new PBException("error generating XDocument node is neither a XElement nor a XDocument");
                }
            }
        }