Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Simple Filter Question

Simple Filter Question

Scheduled Pinned Locked Moved XML / XSL
csharpxmlhelphtmlvisual-studio
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Glenn E Lanier II
    wrote on last edited by
    #1

    I am venturing into the .NET XML world and have already run into a problem. I have some very simple (I think) XML that defines several loan rate values, with attributes indicating the min and max amount for the loan: 10.25 14.75 5.25 9.75 So, a loan for $2500.00 should have a margin of 10.25/floor of 14.75, while a loan of $7500.00 should have a margin of 5.25/floor of 9.75. I want to access these values in my C# code to calculate the rate/payment, but am stuck. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath(@"~\App_Data\LoanInformation.xml")); string xPath = string.Format("//LoanRates/Loan[@MinValue >= '{0:000000.00}' and @MaxValue <= '{0:000000.00}']", plcdata.LoanAmount); XmlNode node = xmlDoc.SelectSingleNode(xPath); node seems to always be null, unless I remove the 'and @Max ..' clause. I added the leading zero's in case text vs. number comparison was causing a problem. Any pointers would be greatly appreciated. --G -- modified to "ignore HTML tags"

    P 1 Reply Last reply
    0
    • G Glenn E Lanier II

      I am venturing into the .NET XML world and have already run into a problem. I have some very simple (I think) XML that defines several loan rate values, with attributes indicating the min and max amount for the loan: 10.25 14.75 5.25 9.75 So, a loan for $2500.00 should have a margin of 10.25/floor of 14.75, while a loan of $7500.00 should have a margin of 5.25/floor of 9.75. I want to access these values in my C# code to calculate the rate/payment, but am stuck. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Server.MapPath(@"~\App_Data\LoanInformation.xml")); string xPath = string.Format("//LoanRates/Loan[@MinValue >= '{0:000000.00}' and @MaxValue <= '{0:000000.00}']", plcdata.LoanAmount); XmlNode node = xmlDoc.SelectSingleNode(xPath); node seems to always be null, unless I remove the 'and @Max ..' clause. I added the leading zero's in case text vs. number comparison was causing a problem. Any pointers would be greatly appreciated. --G -- modified to "ignore HTML tags"

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Your XPath query is incorrect. Your code should read:

      XmlDocument xmlDoc = new XmlDocument();
      xmlDoc.Load(Server.MapPath(@"~\App_Data\LoanInformation.xml"));
      string xPath = string.Format("//LoanRates/Loan[@MinValue <= '{0:000000.00}' and @MaxValue >= '{0:000000.00}']", plcdata.LoanAmount);
      XmlNode node = xmlDoc.SelectSingleNode(xPath);

      Paul Marfleet

      G 1 Reply Last reply
      0
      • P pmarfleet

        Your XPath query is incorrect. Your code should read:

        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath(@"~\App_Data\LoanInformation.xml"));
        string xPath = string.Format("//LoanRates/Loan[@MinValue <= '{0:000000.00}' and @MaxValue >= '{0:000000.00}']", plcdata.LoanAmount);
        XmlNode node = xmlDoc.SelectSingleNode(xPath);

        Paul Marfleet

        G Offline
        G Offline
        Glenn E Lanier II
        wrote on last edited by
        #3

        Duh! I've been trying various combinations, *assuming* the problem was XML (and my lack thereof) related. Stupid logic! Thanks. --G

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups