HOME

XPath Tutorial
XPath HOME
XPath Intro
XPath Syntax
XPath Locations
XPath Expressions
XPath Functions
XPath Examples

Please visit our sponsors !

XPath Functions

Previous Next

XPath contains a function library for converting data.


XPath Function Library

The XPath function library contains a set of core functions for converting and translating data.


Node Set Functions

Name Description
count() Returns the number of selected elements
id() Selects elements by their unique ID
last() Returns a number equal to the context size from the expression evaluation context
local-name() Returns the local part of the expanded-name of the node in the argument node-set that is first in document order
name() Returns the name of an element
namespace-uri() Returns the namespace URI of the expanded-name of the node in the argument node-set that is first in document order
position() Returns a number equal to the context position from the expression evaluation context

String Functions

Name Description Example & Result
concat() Returns the concatenation of its arguments concat('The',' ','XML')

Result: 'The XML'

contains() Returns true if the first string contains the second string, otherwise it returns false

contains('XML','X')

Result: true

normalize-space() Removes leading and trailing spaces from a string normalize-space(' The XML')

Result: 'The XML'

starts-with() Returns true if the first string starts with the second string, otherwise it returns false starts-with('XML','X')

Result: true

string() Converts an object to a string string(3.14)

Result: '3,14'

string-length() Returns the number of characters in a string string-length('Beatles')

Result: 7

substring() Returns a substring substring('Beatles',1,4)

Result: 'Beat'

substring-after() Returns a substring after a substring

substring-after('12/10','/')

Result: '10'

substring-before() Returns a substring before a substring substring-before('12/10','/')

Result: '12'

translate() Translate letters in a string translate('12:30',':','!')

Result: '12!30'

Number Functions

Name Description Example & Result
ceiling() Returns the smallest integer that is not less than the argument ceiling(3.14)

Result: 4

floor() Returns the largest integer that is not greater than the argument

floor(3.14)

Result: 3

number() Converts its argument to a number

number(price)

round() Returns the integer that is closest to the argument round(3.14)

Result: 3

sum() Returns the sum, for each node in the argument node-set, of the result of converting the string-values of the node to a number sum(/cd/price)

Boolean Functions

Name Description Example & Result
boolean() Converts its argument to Boolean  
false() Returns false number(false())

Result: 0

lang()    
not() Returns true if its argument is false, and false otherwise not(false())
true() Returns true

number(true())

Result: 1



Previous Next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISCart
ASP Ecommerce & Shopping Cart


Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search