I want to check if there is an inline stylesheet within the document, but I am not sure how to pick descendant attributes of an element as "style" attribute could be attached to any element within the body element. This is the current xpath I write:
descendant::@*[self::@style]
But the parser throws error saying: "Unexpected token "@" after axis name". Can anyone tell me how do I fix it or there is another way of doing this? Thanks!
So, you are looking for any element anywhere within the document that has an @style
attribute I think.
If you want the element that contains the attribute you want to the following:
descendant::*[@style]
That will return all descendant elements of the current node that have an @style
attribute. If you wanted the attribute itself you would be better off using something like:
descendant::*[@style]/@style
That will find you all the style attributes themselves.