Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

rpaquixote

Programmer
Feb 8, 2011
2
US
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', '012345678'))>number(45000)]";
XmlNodeList nodes = XDoc.SelectNodes(xpath);

(I'm using C#)

Does anyone know the correct syntax??

THANKS!
 
Figured it out:

string xpath = "//models/model[translate(price, \"$,\", \"\")>45000]";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top