I need to filter a XPath expression to grab only a certain attribute as not empty.
I tried this:
<xsl:template match="DocumentElement/QueryResults[string(@FileName)]">
and this:
<xsl:template match="DocumentElement/QueryResults[string-length(@FileName)>0]">
but it did not work. I need the same kind of data returning from the folloing XPath expression…
<xsl:template match="DocumentElement/QueryResults">
… but filtered to avoid items with empty attribute @FileName.
Thanks!
Since
FileNameis a child element and not an attribute, you need to access it as such and not use the attribute qualifier@in front of the node name.Try:
This will select the
DocumentElement/QueryResultselements that have aFileNamechild element.If, however, you always have a
FileNamechild element (sometimes empty) and you want to select the non empty ones, try this: