Example #1
0
        private void XmlConvert(dom.Node jNode, XmlNode nNode)
        {
            XmlDocument document = nNode.OwnerDocument;

            if (document == null)
            {
                document = (XmlDocument)nNode;
            }

            XmlNode n = null;

            switch (jNode.getNodeType())
            {
            case 1:
                n = document.CreateNode(XmlNodeType.Element, jNode.getNodeName(), jNode.getNamespaceURI());
                break;

            case 4:
                n = document.CreateNode(XmlNodeType.CDATA, jNode.getNodeName(), jNode.getNamespaceURI());
                break;

            default:
                return;
            }
            //set value
            n.InnerText = jNode.getNodeValue();
            nNode.AppendChild(n);

            //copy attributes
            org.w3c.dom.NamedNodeMap nm = jNode.getAttributes();
            for (int i = 0; i < nm.getLength(); i++)
            {
                XmlAttribute a = document.CreateAttribute(nm.item(i).getNodeName());
                a.Value = nm.item(i).getNodeValue();
                n.Attributes.Append(a);
            }

            //copy childs
            org.w3c.dom.NodeList nl = jNode.getChildNodes();
            for (int i = 0; i < nl.getLength(); i++)
            {
                XmlConvert(nl.item(i), n);
            }
        }