Memorize xml document operation
I have not write codes about operating xml document by C# for months. Almost forget all...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using Sportingbet.net;
using Sportingbet.util;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Xml;
class Program
{
static void Main(string[] args)
{
string xml = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "tmp.xml");
XDocument xDoc = XDocument.Parse(xml);
var nodes = from e in xDoc.XPathSelectElements("//myTag")
select e;
foreach (var e in nodes)
{
Console.WriteLine(e);
}
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xml);
XmlNodeList nodelist = xmlDoc.SelectNodes("//myTag");
foreach (XmlNode e in nodelist)
{
Console.WriteLine(e.OuterXml);
}
}
}