Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  XML (Extensible Markup Language)

ancestor Method


Finds the nearest ancestor matching the pattern. It returns either a single element result or null.

Syntax

ancestor(pattern)

Parameters

pattern
Pattern to be matched.

Remarks

The ancestor method can start a filter, but can't appear to the right of a '/' or '//' in a pattern.

This method always returns a single element result or null. If used in expressions, null evaluates to false.

This method is restricted to operating on single nodes or on collections that can be cast to a single node. (A collection can be cast to a node if at most it can have one element in it. For example, author[1] can be cast to a node, whereas book/author[1] cannot.)

Examples

Find the nearest book ancestor of the current element:

ancestor(book)

Find the nearest ancestor author element that is contained in a book element:

ancestor(book/author)


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site