Converting XElement into XmlNode

前端 未结 6 1488
逝去的感伤
逝去的感伤 2021-02-12 06:56

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

6条回答
  •  逝去的感伤
    2021-02-12 07:35

    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); 
    

提交回复
热议问题