Trending September 2023 # How Xpath Wildcard Work With Examples? # Suggested October 2023 # Top 16 Popular |

Trending September 2023 # How Xpath Wildcard Work With Examples? # Suggested October 2023 # Top 16 Popular

You are reading the article How Xpath Wildcard Work With Examples? updated in September 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How Xpath Wildcard Work With Examples?

Definition of X Path Wildcard

XPath wildcard is defined as a special character used in XML language to do access in the selection process of Xpath Expressions to save time. So far, we specified elements by their names but with this wildcard, we can do the selection process for more than one element at a time. XPath wildcard replaces the literal name of a given node making the Xpath more robust. And these wildcard steps are preferable when the XML element names are unknown and promoted as a shorthand notation to consider a set of elements.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Explanation of XPath Wildcard

S No

Wild card Types


1    * This type prefers to match any node in the XML document. You can select more than one element regardless of the type.

2    .

This matches the current node in the context

3    @* This type of wildcard matches any given attribute in the document. Appears in the expression as if it is nested.

4  node()

How XPath Wildcard Work with Examples?

To understand this let us use chúng tôi file to learn XPath wildcards and its style sheet which uses Xpath expressions to select a value from the elements. The most widely used type is the asterisk(*).


The general Xpath expression for the element node is given as :


Hence the asterisk character ‘*’ matches all the element node, therefore, all the above XPath expressions are replaced by

To match all nodes below expression is used and the (//) operator denotes a descendant type wildcard.


Matching child nodes


To select every child of the root node and also child element of a certain element is illustrated as


The above Xpath expression states that the root element Furniture is specified following them we had selected each child of furniture with a wildcard as Furniture/*, hence the currently selected element is wood and glass. And now the children of glass and wood is selected with fur2niture /*/*/* which provide us like third level of nesting.

Matching all the elements with an attribute


It matches any element with an attribute defined.

To navigate the current nodes single period (.)is used.



This returns all child nodes of Kitchen no matter of attributes, text or elements.

Example #1

Now lets see an example of above wildcards using xml and xsl. For the given information in the XML document the XSL style sheets styles and selects a particular value and attributes with the help of Wildcards to display a specific element in the Final result. Let’s start with

course.xml cour.xsl

See here the templates select the root node ‘tutorial’ with the Symbol specified by wildcard (/*) in which the child element attribute is taken by the expression (@ attribute, here it is @idno) hence in the output it displays only the attribute value, not a name. Similarly, all the child elements and their value in displayed one after the other.

Example #2

Here we use a Table format to display the elements of a node.

movie.xml mvs.xsl



Coming to the end this article covers a brief note on the wildcard of Xpath. They could be used in a wide variety of ways and by this lesson we should have a good beginning at considering the pattern we need for any particular application. Also, we have seen a detailed practical example that shows how wildcard works for a specific scenario in the Xpath Expression.

Recommended Articles

This is a guide to XPath Wildcard. Here we also discuss the introduction and how does XPath wildcard work? along with different examples and its code implementation. You may also have a look at the following articles to learn more –

You're reading How Xpath Wildcard Work With Examples?

Update the detailed information about How Xpath Wildcard Work With Examples? on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!