A NullReferenceException
is thrown by the runtime when I convert XElement into XmlNode using the following function:
public static XmlNode GetXmlNode(this XElement element)
{
using (XmlReader xmlReader = element.CreateReader())
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
xmlDoc.ChildNodes[4].InnerXml = "0.15"; ====> null reference exception occurs here
return xmlDoc;
}
}
How can I convert XElement to XmlNode without this problem?