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. C#
  4. Case Sensitive Issue with XML

Case Sensitive Issue with XML

Scheduled Pinned Locked Moved C#
helpquestionalgorithmsxml
2 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.
  • L Offline
    L Offline
    Latheesan
    wrote on last edited by
    #1

    Hi, Im trying to do a simple XML Record Lookup using the following code: string fileName = "Account_Data.xml"; XPathDocument doc = new XPathDocument(fileName); XPathNavigator nav = doc.CreateNavigator(); XPathExpression expr; expr = nav.Compile("/Accounts/Account[FirstName='" + nameTextBox.Text + "']"); XPathNodeIterator iterator = nav.Select(expr); iterator = nav.Select(expr); if (iterator.MoveNext()) { // Record Found } else { // Record Not Found, So Create A New One Here } It works just fine, but there seem to be a minor bug with it. In the XML file, i already have a record with Latheesan, so when i searched using my search form for "latheesan", it returned 0 results, hense it created a new record. How can i avoid case sensitiveness issues with searching through XML Records?

    S 1 Reply Last reply
    0
    • L Latheesan

      Hi, Im trying to do a simple XML Record Lookup using the following code: string fileName = "Account_Data.xml"; XPathDocument doc = new XPathDocument(fileName); XPathNavigator nav = doc.CreateNavigator(); XPathExpression expr; expr = nav.Compile("/Accounts/Account[FirstName='" + nameTextBox.Text + "']"); XPathNodeIterator iterator = nav.Select(expr); iterator = nav.Select(expr); if (iterator.MoveNext()) { // Record Found } else { // Record Not Found, So Create A New One Here } It works just fine, but there seem to be a minor bug with it. In the XML file, i already have a record with Latheesan, so when i searched using my search form for "latheesan", it returned 0 results, hense it created a new record. How can i avoid case sensitiveness issues with searching through XML Records?

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Never done this myself, but I think you can only avoid case sensitiveness by turning both the search string as well as the content of FirstName to either upper or lower case. For the search string you can use the appropriate methods provided by the String class. In case of the content of FirstName you'll have to use XPath functions[^].


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      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