xpath expression to remove whitespace

I. Use this single XPath expression: translate(normalize-space(/tr/td/a), ‘ ‘, ”) Explanation: normalize-space() produces a new string from its argument, in which any leading or trailing white-space (space, tab, NL or CR characters) is deleted and any intermediary white-space is replaced by a single space character. translate() takes the result produced by normalize-space() and produces a … Read more

XPath – Get node with no child of specific type

Maybe *[local-name() = ‘A’ and not(descendant::*[local-name() = ‘B’])]? Also, there should be only one root element, so for /A[…] you’re either getting all your XML back or none. Maybe //A[not(B)] or /*/A[not(B)]? I don’t really understand why /A[not(B)] doesn’t work for you. ~/xml% xmllint ab.xml <?xml version=”1.0″?> <root> <A id=”1″> <B/> </A> <A id=”2″> </A> … Read more

Xpath: select div that contains class AND whose specific child element contains text

To find a div of a certain class that contains a span at any depth containing certain text, try: //div[contains(@class, ‘measure-tab’) and contains(.//span, ‘someText’)] That said, this solution looks extremely fragile. If the table happens to contain a span with the text you’re looking for, the div containing the table will be matched, too. I’d … Read more

XPath test if node value is number

Test the value against NaN: <xsl:if test=”string(number(myNode)) != ‘NaN'”> <!– myNode is a number –> </xsl:if> This is a shorter version (thanks @Alejandro): <xsl:if test=”number(myNode) = myNode”> <!– myNode is a number –> </xsl:if>

How to use not contains() in XPath?

XPath queries are case sensitive. Having looked at your example (which, by the way, is awesome, nobody seems to provide examples anymore!), I can get the result you want just by changing “business”, to “Business” //production[not(contains(category,’Business’))] I have tested this by opening the XML file in Chrome, and using the Developer tools to execute that … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)