1,150 views
1 votes
1 votes

Consider the XML document fragment given below:

<Book>
<Title>GATE 2K7 Example<Title>
<Content>
             One of many lines 
</Content>
<TOC>
One of many content entries
</TOC>
</Book>


Consider the XPath expression: *[not (self ) : : TOC]
What would be the result of the given XPath expression when the current node is Book?

  1. The Title and Content elements
  2. The Content and TOC elements
  3. The Title and TOC elements
  4. The Title, Content and TOC elements

1 Answer

1 votes
1 votes
Ans A)

XPath can be used to navigate through elements and attributes in an XML document.

I think *[not(self)::TOC] is not syntactically correct so we might get a syntax error.

It should be *[not(self::TOC)] instead which would select all child elements of the Book element that are not TOC elements so the Title element and the Content element will be selected.
edited by
Answer:

Related questions