SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on some DOM scraping in SP and I want to tighten up my logic around web-parts. Namely, is it safe to say that anything with a attribute of 'webpartid' is a webpart?

Some sample environments I've been in have lots of elements with this attribute that look empty/useless.

Alternatively, can I say that anything with an id = 'webpart' is a webpart? Those counts don't add up btw...

EDIT: or, is it any element with both of those attribute criteria?

share|improve this question
up vote 1 down vote accepted

The following assumes SP2010. You would be 100% safe assuming that a DIV element with a webpartid attribute is the body container for the web part. If you want to find the starting point for a webpart (i.e. the chrome), look for table elements with a class attribute of s4-wpTopTable.

share|improve this answer
You can also narrow down the correct element by using the developer tools built in to IE (or Chrome as well). Hit F12 to bring up the dev window. Then select the pointer icon (or hit Ctrl+B while in the dev window). You can then use your mouse to select the element on the html page. A blue window is displayed around the 'selected' DOM element. Click the mouse button and the dev window navigates to the selected DOM element. – Rich Ross Jul 28 '11 at 2:35
Excellent tip Rich! – Rob D'Oria Jul 28 '11 at 2:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.