EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials XML Tutorial XPath Matches
Secondary Sidebar
XML Tutorial
  • Xpath
    • What is XPath?
    • XPath namespace
    • XPath for JSON
    • XPath Last Element
    • Xpath Substring
    • XPath First Element
    • XPath local-name
    • XPath Multiple Attributes
    • XPath Matches
    • XPath Position
    • XPath Index
    • XPath regex
    • XPath id contains
    • XPath innertext
    • XPath Multiple Conditions
    • XPath Helper
    • XPath Generator
    • XPath ID
    • XPath Locator
  • Basic
    • What is XML?
    • XML Tags
    • XML URL
    • XPath Sibling
    • XML root element
    • XML Encryption
    • XML Parsing php
    • xml parsing with java
    • Dataset XML
    • XML Parser in C#
    • XML Tree
    • XML boolean
    • XML sitemap
    • XML Array
    • XML reserved characters
    • XML Viewer
    • XML Uses
    • XML Special Characters
    • XML generator
    • XML file format
    • XML DOM
    • XML ampersand
    • XML Mapping
    • XML File
    • XML Element
    • XML HttpRequest
    • XML XSD
    • XML Schema
    • XML Namespaces
    • XML Comments
    • XML Attributes
    • XML Encoding
    • XML Validation
    • XML CDATA
    • XML Database
    • XML Technologies
    • XML Error
    • XML DTD
    • XML Date
    • XML Parsers
    • String in XML
    • XML with CSS
    • XML Versions
    • XML Features
    • XML Commands
    • Servlet web.xml
    • XPath Injection
    • XPath Functions
    • XPath starts-with
    • XPath Selector
    • XPath Count
    • XPath XML
    • XML Parsing in Oracle
    • XML parsing in python

XPath Matches

XPath Matches

Definition of XPath Matches

XPath matches allow us to use an expression of XPath for selecting content from the target request or the response node for comparing the value which we expect. The matches are applied to the requests and responses from the xml data in the body. Ready API is not parsing the xml documents which contain the character of byte order mark for the XPath match expression.

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,950 ratings)

What is XPath matches?

The standard of W3C for the XQuery 1.0 and XPath 2.0 operator and function will be defining the three functions i.e. replace, match and tokenize which take a regular expression as parameters. The XPath and xquery standard will introduce the new regular expressions, it is identical to the xml schema by using additional features of the modern flavors of regex. All the valid xml schema is valid for the XPath regex. Feature of xml schema is used in a validity test, this feature will eliminate from the performance reasons, XPath function is performing the more complex regular expressions.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

XPath Matches Function

  • The matches function is returning the true if the supplied string will match the given regular expressions. Below is the signature of the XPath matches function is as follows.

Signatures –

Fn : matches (
$input as xs : string?,
$pattern as xs : string
) as xs : boolean
Fn : matches (
$input as xs : string?,
$pattern as xs : string,
$flags as xs : string
) as xs : boolean
  • The function is context-independent focused independent and deterministic. Basically, the effect of calling this first version of the function is the same as the effect of calling the second version with the argument of $flags for setting it to the zero-length string.
  • Matches function flags are defined in a @input in the sequence of empty, and it was interpreted as a string of zero length.
  • The function of matches is returning a true if the $input or another substring of $input will match the regular expression which was supplied by using $pattern. Otherwise, the function of matches will return false.
  • The matching rule of matches function will influenced by the value as $flags if it is present.
  • Below is the example of matches function are as follows.

Example –

fn : matches ("abcpqrxyz", "pqr") returns true()
fn : matches ("abcpqrxyz ", "^a.*a$") returns true()
fn : matches ("abcpqrxyz ", "^pqr") returns false()

1-1

  • The following function call will produces the results as follows. By using the element of poem in a context node.

Example –

fn : matches ($ABC, "pqr.*xyz") returns false()
fn : matches ($ABC, "pqr.*xyz", "s") returns true()
fn : matches ($ABC, "^pqr.*PBC,$", "m") returns true()
fn : matches ($ABC, "^pqr.*PBC,$") returns false()
fn : matches ($ABC, "kiki", "i") returns true()

1-2

  • In the XPath matched function the dynamic error will be raised if the value of the $pattern is invalid as per the rule described in the XPath matches function.
  • In the XPath matched function the dynamic error will be raised if the value of $flags is invalid as per the rule described in the XPath matches function.
  • In XPath, the matches function the meta characters ^ and $ is used as anchors and the string is used to consider as pattern matching if any substring will matches a pattern. Basically, anchors are used to starting and end of the string of used to start and end of the line. We can say that it is different from the pattern behavior where the regular expression will anchor implicitly.
  • Matching of regular expression is defined on the basis of points of Unicode it will take no account with collations.

XPath Matches Method

  • XPath matches method will be determining whether the current node will match the specified expression of system xml XPath.
  • Below is the method of XPath match are as follows, XPath matches method contains the two methods.
  • Matches (string) – This method will determine whether the current node will match the specified XPath expression or not. This method is taking the input as a string value.
  • This method contains the XPath expression as a parameter. It will return the boolean as a true value while matching the current node XPath expression otherwise it will return the false value. Below is the example of matched methods as follows.

Code –

<?xml version = "1.0" encoding = "utf-8" ?>
<School>
<stud name = "ABC" addr = "Pune" std = "4th">
<phone_no> 1234567890 </phone_no>
<school_info>
<school-name> International school </school-name>
<school_addr> Mumbai </school_addr>
</school_info>
</stud>
</school>

XPath Matches 1-3

  • Matches (XPathExpression) – This method will determine whether the current node will match the specified XPath expression or not. This method is taking the input as an XPath expression value. Basically, this method will determine whether the current node will match the specified expression of XPath.
  • Below is the example of matches method in XPath expression as follows.

Code –

<?xml version = "1.0" encoding = "utf-8" ?>
<Organization>
<Employee name = "ABC" addr = "Pune">
<phone_no> 1234567890 </phone_no>
<company_info>
<name> PQR </name>
<addr> Mumbai </addr>
</company_info>
</Employee>
<Employee name = "PQR" addr = "Mumbai">
<phone_no> 1234567890 </phone_no>
<company_info>
<name> ABC </name>
<addr> Pune </addr>
</company_info>
</Employee>
<Employee name = "XYZ" addr = "Chennai">
<phone_no> 1234567890 </phone_no>
<company_info>
<name> CBD </name>
<addr> Chennai </addr>
</company_info>
</Employee>
</Organization>

XPath Matches 1-4

Matches XPathExpression

  • The matches XPath expression will be determining the current node of the specified expression.
  • The XPath expression will contain the compiled expression of XPath. It will contain the expr as parameter values.
  • The XPath expression will be returning the Boolean value which was true, if the current node will match the expression of XPath otherwise it will return a false value.
  • In XPath expression, we cannot evaluate the argument expression if the XPath expression is not valid.
  • Below is the example of the XPath expression as follows.

Code –

<?xml version = "1.0" encoding = "utf-8" ?>
<Student>
<Stud name = "ABC" addr = "Mumbai">
<phone_no> 1234567890 </phone_no>
<stud_info>
<name> PQR </name>
<addr> Mumbai </addr>
</stud_info>
</Stud>
<Stud name = "PQR" addr = "Mumbai">
<phone_no> 1023456789 </phone_no>
<stud_info>
<name> ABC </name>
<addr> Pune </addr>
</stud_info>
</Stud>
</Student>

XPath Matches 1-5

Conclusion

The XPath and xquery standard will introduce the new regular expressions, it is identical to the xml schema. XPath matches allow us to use an expression of XPath for selecting content from the target request or the response node for comparing the value which we expect.

Recommended Articles

This is a guide to XPath Matches. Here we discuss the Definition, What is XPath matches, and examples with code implementation respectively. You may also have a look at the following articles to learn more –

  1. XPath regex
  2. XPath namespace
  3. Scrapy XPath
  4. XPath contains
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more