XPATH finds the specified class element

Source: Internet
Author: User

After all, XPath can parse the corresponding element from a formatted HTML lookup more quickly.

More formal site layout, you can copy the XPath path directly through Chrome's debugger. :

However, this approach may not be effective and will not get a set of values that are correctly searched.

How to find the content of an element that specifies class= ' xxx ' through XPath.

Documentnode.selectnodes ("//div[@class = ' Mainarea ']/ul/li");

Everyone can do so by:

div[@class = ' mainarea ') means to find node with a class value of Mainarea from the root (//).

So, then it is very simple//an element [@class = ' class value ']

You can follow this formula to find the elements of class.

The remaining/ul/li represents the collection of LI nodes that continue to look for the class= ' Mainarea ' div including the UL elements below.

Above is just a case. You can view the XPath class


XPATH finds the specified class element

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.