Wildcards in Queries

In a query, you can include an asterisk (*) to represent all elements. For example:



This query searches for all book elements in bookstore. For each book element, this query returns all child elements that the book element contains.

The * collection returns all elements that are children of the context node, regardless of their tag names.

The next query finds all last-name elements that are grandchildren of book elements in the current context:



The following query returns the grandchild elements of the current context.




Usually, the asterisk (*) returns only elements. It does not return processing instructions, attributes, or comments, nor does it include attributes or comments when it maintains a count of nodes. For example, the following query returns title elements. It does not return style attributes.



Wildcards in strings are not allowed. For example, you cannot define a query such as the following:

/bookstore/book[author=" A* "]



To use a wildcard for attributes, you can specify @*. For example:



For each book element, this query returns all attributes. It does not return any elements.

Free Stylus Studio XML Training:
W3C Member