상세 컨텐츠

본문 제목

XPathNavagator 사용하기

AJAX

by happynuri 2008. 2. 14. 16:16

본문

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 xPathNodeIterator = xPathNavi.Select(
                "//booklist/book/title[../@kind='컴퓨터']");

            while (xPathNodeIterator.MoveNext())
            {
                XPathNavigator naviTitle = xPathNodeIterator.Current;
                Console.WriteLine(naviTitle.Value);
            }
        }
    }
}

관련글 더보기

댓글 영역