XPath 노드
XPath 용어
노드
XPath에는 요소, 속성, 텍스트, 네임스페이스, 처리 명령, 주석 및 문서 노드의 7가지 종류의 노드가 있습니다.
XML 문서는 노드 트리로 취급됩니다. 트리의 최상위 요소를 루트 요소라고 합니다.
다음 XML 문서를 보십시오.
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book>
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
위의 XML 문서에 있는 노드의 예:
<bookstore> (root element node)
<author>J K. Rowling</author> (element node)
lang="en" (attribute node)
원자 값
원자 값은 자식이나 부모가 없는 노드입니다.
원자 값의 예:
J K. Rowling
"en"
아이템
항목은 원자 값 또는 노드입니다.
노드의 관계
부모의
각 요소와 속성에는 하나의 부모가 있습니다.
다음 예에서; book 요소는 제목, 저자, 연도 및 가격의 상위 요소입니다.
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
어린이들
요소 노드에는 0개, 하나 이상의 자식이 있을 수 있습니다.
다음 예에서; 제목, 저자, 연도 및 가격 요소는 모두 book 요소의 하위 요소입니다.
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
형제
동일한 부모가 있는 노드입니다.
다음 예에서; 제목, 작성자, 연도 및 가격 요소는 모두 형제입니다.
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
조상
노드의 부모, 부모의 부모 등
다음 예에서; title 요소의 조상은 book 요소와 bookstore 요소입니다.
<bookstore>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
자손
노드의 자식, 자식의 자식 등
다음 예에서; bookstore 요소의 하위 항목은 책, 제목, 저자, 연도 및 가격 요소입니다.
<bookstore>
<book>
<title>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>