Search code examples
xmlxpathmsxml

Need explanation of XPath syntax


Can anyone explain the XPath syntax written below:

xmlDoc.documentElement.selectNodes("//*/Expression[.!='']")

Basically, I need clarification of the argument path of the above syntax.


Solution

  • Select all the <Expression> elements which:

    1. are not root elements
    2. and have non-empty value

    //*/ - this means any but root

    Expression - element name

    [.!=''] - this means current node value is not empty, i.e. current node . is not != empty ''