티스토리백업xml에서 제목읽기
C:\1.xml 로 저장한 티스토리 백업파일에서 Title가져오기..
<blog>
<post>
<title>제목 </title>
</post>
</blog>
using System;
using System.Xml;
using System.Xml.Linq;
namespace tet
{
class Program
{
public static void Main(string[] args)
{
using (XmlReader reader = XmlReader.Create("c:\\1.xml"))
{
while (reader.Read())
{
// Only detect start elements.
if (reader.IsStartElement())
{
// Get element name and switch on it.
switch (reader.Name)
{
case "title":
// Detect this article element.
Console.WriteLine("Start <article> element.");
// Search for the attribute name on this current node.
string attribute1 = reader["title"];
if (attribute1 != null)
{
Console.WriteLine(" Has attribute name: " + attribute1);
}
// Next read will contain text.
if (reader.Read())
{
Console.WriteLine(" Text node: " + reader.Value.Trim());
}
break;
}
}
}
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}