Converting XElement into XmlNode

前端 未结 5 1935
死守一世寂寞
死守一世寂寞 2021-02-12 07:17

I know there is no direct method of doing it but still.. Can we convert XElement element into XmlNode. Options like InnerText and

5条回答
  •  遥遥无期
    2021-02-12 07:34

    Here is converting from string to XElement to XmlNode and back to XElement. ToString() on XElement is similar to OuterXml on XmlNode.

        XElement xE = XElement.Parse("");
    
        XmlDocument xD = new XmlDocument();
        xD.LoadXml(xE.ToString());
        XmlNode xN = xD.FirstChild;
    
        XElement xE2 = XElement.Parse(xN.OuterXml); 
    

提交回复
热议问题