XML 문서를 XmlDocument를 이용해 생성한다. 기본으로 유니코드로 저장하기 때문에 한글이 깨지는 문제가 발생하는데, 이 때문에 이 방법 보다는 XmlWriter를 이용해서 XmlWriter.create를 이용해 문서를 생성하는 방법이 더 나은것 같다. using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml; namespace CH11 { class p575_NewDOM { static void Main() { XmlDocument xDoc = new XmlDocument(); XmlElement eBookList = xDoc.CreateElement("booklist"..
이번 예제에서는 Element, Attribute를 DOM을 이용해 삭제하는 방법을 다룬다. (읽어들일 XML문서는 이전에 포스팅한 글을 참조한다) using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml; using System.IO; namespace CH11 { class p574_Remove { static void Main() { string filePath = @"..\..\booklist.xml"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(filePath); XmlElement eBookList = xDoc.Document..
(불러들이는 XML 파일은 이전에 포스트한 글을 참조한다) 이 글에서는 Xml 문서를 읽어들여 값을 수정하는 예제를 보여준다. .InnerText와 SetAttribute()를 보도록 하자. using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml; using System.IO; namespace CH11 { class p568_AddNewContent { static void Main() { string filePath = @"..\..\booklist.xml"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(filePath); XmlEl..
using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml; using System.IO; namespace CH11 { class p568_AddNewContent { static void Main() { string filePath = @"..\..\booklist.xml"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(filePath); XmlElement eBookList = xDoc.DocumentElement; XmlElement eBook = xDoc.CreateElement("book"); eBook.SetAttribute("..
사용한 XML 문서는 이전 글을 참조하기 바란다. using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml.XPath; namespace CH11 { class p566_XPathNavagator { static void Main() { string filePath = @"..\..\booklist.xml"; XPathDocument xPathDoc = new XPathDocument(filePath); XPathNavigator xPathNavi = xPathDoc.CreateNavigator(); // XPath 반복기 XPathNodeIterator xPathNodeIter..
읽어들일 XML 파일 'booklist.xml' 기초에서 실무까지 XML 신민철 프리렉 35000 사랑과 전쟁 이사랑 전쟁문화사 15000 마이크로 소프트 빌 게이츠 마소문화사 20000 액션가면부인 바람났네 짱구 짱구출판사 12000 Xml Node를 XPath를 이용해서 선택하는 예제이다. 예제에서는 kind가 '컴퓨터'인 node를 선택하는 예제코드를 보여준다. using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.Xml; namespace CH11 { class p564_FindXPath { static void Main() { string filePath = @"..\..\..