Extensions class ımıza aşağıdaki çevrim kodlarını ekleyip kullanmaya başlayabiliriz.
public static XElement getXElement(this XmlNode xn)
{
return XElement.Parse(xn.OuterXml);
}
public static XmlNode getXmlNode(this XElement xe)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(xe.ToString());
return xd;
}
Programda kullanımı ise ;
static void Main(string[] args)
{
XElement xE = new XElement("Document");
xE.Add(new XElement("Body", (new XAttribute("font", "1"))));
xE.Element("Body").SetElementValue("Body", "deneme yazısı");
XmlNode xn = xE.getXmlNode();
Console.WriteLine(xn.OuterXml);
XElement xe = xn.getXElement();
Console.WriteLine(xe);
}
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5