![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XPath LT & GT: problems when comparing strings! >Thread Next - Re: XPath LT & GT: problems when comparing strings! Re: XPath LT & GT: problems when comparing strings!To: NULL Date: 9/5/2006 3:10:00 PM Dmitry Bond. wrote: > Something strage happens when I try to compare a string value (value of > XML attribute) with ">", "<" or ">=", "<=" operators. Looks like only > "=" works for strings comparison in MSXML. :-( Right, XPath 1.0 does not support < or > comparison of strings, instead those operators always convert their operands to the XPath number type and then compare numbers. With MSXML there is an extension function provided for string comparison e.g. var xmlDocument = new ActiveXObject('Msxml2.DOMDocument.4.0'); xmlDocument.loadXML('<god>Kibo</god>'); xmlDocument.setProperty('SelectionNamespaces', 'xmlns:ms="urn:schemas-microsoft-com:xslt"'); xmlDocument.selectNodes( 'god[ms:string-compare(., "Xibo") <= -1]').length gives 1 See <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/20616b82-9e27-444c-b714-4f1e09b73aee.asp> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
