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. XPath Doubt

XPath Doubt

Scheduled Pinned Locked Moved XML / XSL
xmlcsharphelptutorialquestion
1 Posts 1 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.
  • A Offline
    A Offline
    Ajith Kumar
    wrote on last edited by
    #1

    Hi all, I have the following sample XML file Locale Equivalent of above id string I load the xml document document using the XmDocument.Load( fileName) in C#. Sample code string idvalue = "%s\"Hello\'s World\""; string path = "/ROOT?STRING[@id = \"" + idvalue + "\"]/LOCALE"; // so as to get the text between LOCALE tag XmlDocument doc = new XmlDocument(); doc.Load(fileName); string str = doc.DocumentElement.SelectSingleNode(path).InnerXml; Howvever the the statement throws an exception because the quotes in the path string is not escaped in XML. SelectSingleNode() takes an XPATH expression. How to escape the quotes in an XPATH expression so that the last statement works correctly. The last expression is a problem only when their is a " in id attribute, since the attribute value is enclosed in quotes in Xpath. for id attribute values with no quotes takes me correctly to the text betwen LOCALE tag The XML is successfully validated internally aginst a DTD. The XML file contains ", ', &, <, > in their encoded form. Any solutions to offer Regards, Ajith

    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