DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XPATH: Hot to convert $XX,XXX to number to filter with xpath

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    XPATH: How to convert $XX,XXX to number to filter with xpath

    I have an xml doc formatted as follows:

    <models>
    <model>
    <name>model 1</name>
    <price>$20,000</price>
    </model>
    <model>
    <name>model 2</name>
    <price>$50,000</price>
    </model>
    </models>


    I need to get all nodes greater than $45,000. I have the following XPATH (which does not work):

    string xpath = "//models/model[number(translate(price, '0123456789$,', '0123456789'))>number(45000)]";
    XmlNodeList nodes = XDoc.SelectNodes(xpath);


    (I'm using C#)
    Does anyone know the correct syntax??

    THANKS!
    Last edited by rpamavalon; 02-08-2011 at 06:41 PM.

  2. #2
    Join Date
    Feb 2011
    Posts
    2
    Figured it out:

    string xpath = "//models/model[translate(price, \"$,\", \"\")>45000]";

Similar Threads

  1. Need to Convert a Hex string to a Hex number
    By Dan Fergus in forum .NET
    Replies: 3
    Last Post: 08-23-2001, 01:39 PM
  2. Replies: 3
    Last Post: 07-03-2001, 11:10 AM
  3. Convert positive to negative number..
    By pat mitchell in forum VB Classic
    Replies: 7
    Last Post: 03-29-2001, 03:52 PM
  4. convert a hexadecimal number to a string
    By Dirk in forum Database
    Replies: 0
    Last Post: 07-18-2000, 07:10 AM
  5. Convert text to number in SQL
    By John in forum VB Classic
    Replies: 2
    Last Post: 07-13-2000, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center