XPath Find Elements with specific Attribute

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]”

Published by

Unknown's avatar

Tim Clark

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. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

4 thoughts on “XPath Find Elements with specific Attribute

  1. 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!

    Like

  2. 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.

    Like

Leave a reply to schleichermann Cancel reply