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 query

XPath query

Scheduled Pinned Locked Moved XML / XSL
xmldatabasehelpquestionlearning
4 Posts 3 Posters 10 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.
  • J Offline
    J Offline
    Jan R Hansen
    wrote on last edited by
    #1

    Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan

    C P 2 Replies Last reply
    0
    • J Jan R Hansen

      Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan

      C Offline
      C Offline
      Christopher Lord
      wrote on last edited by
      #2

      make sure your using something newer than msxml2, which does not support string-length. some resources: http://www.w3.org/TR/xpath http://www.vbxml.com/xsl/XPathRef.asp http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html?stylesheetFile=XSLT/xpath.xslt&lang=eng

      J 1 Reply Last reply
      0
      • C Christopher Lord

        make sure your using something newer than msxml2, which does not support string-length. some resources: http://www.w3.org/TR/xpath http://www.vbxml.com/xsl/XPathRef.asp http://www.zvon.org:9001/saxon/cgi-bin/XLab/XML/extras.html?stylesheetFile=XSLT/xpath.xslt&lang=eng

        J Offline
        J Offline
        Jan R Hansen
        wrote on last edited by
        #3

        Thanks for the links - actually useful ;) I solved the problem yesterday by using @name != "" - but thanks anyway. /Jan

        1 Reply Last reply
        0
        • J Jan R Hansen

          Hi all, I just need some help with an XPath query. I have a document like ... ... ... and I would like to get (from a pointer to my_items) all elements with a "name" attribute where the attribute is not empty. That would be item 1 and 2 above. I've tried with a query like _bstr_t bstrQuery = "item[(string-length(@name) > 0)]"; - but it doesn't work. Got any hints ? I really need a useful resource for practical knowledge about XPath. All I've got is Essential XML Quick Reference by Aaron Skonnard and Martin Gudgin. It's definately good - but despite its humble size rather heavy ;) I suppose a reference is supposed to be that though. Well, thanks in advance for any help or pointers. /Jan

          P Offline
          P Offline
          Philip Fitzsimons
          wrote on last edited by
          #4

          correct way is item[not(@name)]


          "When the only tool you have is a hammer, a sore thumb you will have."

          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