Get all elements that have the style attribute => “//*[@style]”
Get all elements where style equals bold => “//*[@style=’bold’]”
Get all elements where style contains the string red => “//*[contains(@style,’red’)]”
Get all customer elements that have the age attribute => “//customer[@age]”
Get all customer that have both age and gender attributes => “//customer[@age and @gender]”
Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director.
View all posts by Tim Clark
4 thoughts on “XPath Find Elements with specific Attribute”
A friend of mine just emailed me one of your articles from a while back. I read that one a few more. Really enjoy your blog. Thanks
I found your site on technorati and read a few of your other posts. Keep up the good work. I just added your RSS feed to my Google News Reader. Looking forward to reading more from you down the road!
Thanks, I am glad you are getting some use out of my blog. I really just started it in order to consolidate the things I learn each day as I develop so I wouldn't have to chase down or keep track of each tutorial, forum, or blog I found answers on. Hopefully it will one day be a one stop resource for anything (.Net, C#, HTML/CSS, XML, etc.) development related.
When I first worked with XPath, I never knew that the thing I am using is XPath, then after a few days, google told me. =D