Html/xml/xpath Foundation

Source: Internet
Author: User
Tags xpath

HTML Hypertext Markup Language

Right-click on Web page → view source file/View source code

HTML BASIC Structure

......

<body> document body, display on browser

......

</body>

use tags in head

<tittle></tittle> document titles are displayed in the title bar

<script></script>

<style></style> referencing CSS Styles

XML Extensible Markup Language

Http://www.yesky.com/imagesnew/software/html/index.html

a language for finding information in an XPath XML document

/Slash Start path instance 1

<AAA>

<BBB/>

<CCC/>

<DDD>

<BBB/>

</DDD>

<CCC/>

</AAA> XPath expression:/aaa Select root element AAA

/Slash Start path instance 2

<AAA>

<BBB/>

  <CCC/>

<DDD>

<BBB/>

</DDD>

  <CCC/>

</AAA> XPath expression:/AAA/CCC Select the sub-element of AAA CCC

/Slash Start path instance 3

<AAA>

<BBB/>

<CCC/>

<DDD>

     <BBB/>

</DDD>

<CCC/>

</AAA> XPath expression:/aaa/ddd/bbb Select child element of AAA DDD element BBB

Start path instance with double slash 1

<AAA>

  <BBB/>

<CCC/>

  <BBB/>

<DDD>

    <BBB/>

</DDD>

<CCC/>

<DDD>

    <BBB/>

    <BBB/>

</DDD>

<CCC/>

</AAA> XPath expression://bbb selects all BBB elements

Start path instance with double Slash 2

<AAA>

<BBB/>

<CCC/>

<BBB/>

<DDD>

    <BBB/>

</DDD>

<CCC/>

<DDD>

    <BBB/>

    <BBB/>

</DDD>

<CCC/>

</AAA> XPath expression://DDD/BBB Select all the parent elements are the BBB elements of DDD

* Start path instance with asterisk 1

<AAA>

<CCC/>

<DDD>

       <BBB/>

      <BBB/>

<EEE/>        

      <EEE/>

</DDD>

<CCC/>

</AAA> XPath expression:/aaa/ccc/ddd/* Select all the paths that are attached to the/aaa/ccc/ddd/element

* Start path instance with asterisk 2

<AAA>

<XXX/>

<DDD>

       <BBB/>

      <BBB/>

<EEE/>

</DDD>

<XXX/>

<CCC/>

<BBB>

       <BBB/>

<BBB/>

<BBB/>       

<BBB/>

<CCC/>

</AAA> XPath expression:/*/*/*/bbb selects all BBB elements with 3 ancestor elements

* Start path instance with asterisk 3

<AAA>                  

  <CCC/>

    </DDD>

  <CCC/>

</AAA> XPath expression://* Select all elements

[] Use square brackets to qualify an element instance 1

<AAA>

  <BBB/>

<BBB/>

<BBB/>

</AAA> XPath expression:/aaa/bbb[1] Select the first BBB child element of AAA

[] Use square brackets to qualify an element instance 2

<AAA>

<BBB/>

<BBB/>

  <BBB/>

</AAA> XPath expression:/aaa/bbb[last ()] Select the last BBB child element of AAA

@ Specify attribute instance by @ 1

<AAA>

<BBB id= "B1"/>

<BBB id= "B2"/>

<BBB name= "BBB"/>

<BBB/>

</AAA> XPath expression://@id Select all ID attributes (note that the attributes of the element are selected, not the element)

@ Specify attribute instance by @ 2

<AAA>

<BBB id= "B1"/>

<BBB id= "B2"/>

<BBB name= "BBB"/>

<BBB/>

</AAA> XPath expression://bbb[@id] Selects the BBB element for all ID attributes (//bbb[@name] selects the BBB element for all name attributes)

@ Specify attribute instance by @ 3

<AAA>

<BBB id= "B1"/>

<BBB id= "B2"/>

<BBB name= "BBB"/>

<BBB/>

</AAA> XPath expression://bbb[@*] Select the BBB element with any attribute

@ Specify attribute instance by @ 4

<AAA>

<BBB id= "B1"/>

<BBB id= "B2"/>

<BBB name= "BBB"/>

  <BBB/>

</AAA> XPath expression://bbb[not (@*)] Select the BBB element with no attributes

Using attribute values as selection criteria 1

<AAA>

<BBB id= "B1"/>

<BBB id= "B2"/>

<BBB name= "BBB"/>

<BBB/>

</AAA> XPath expression://bbb[@id = ' B1 ') Select the BBB element containing the attribute id= ' B1 '

| using the delimiter "|" Merging multiple path instances 1

<AAA>

  <BBB/>

<CCC/>

<DDD>

     <CCC/>

</DDD>

  <EEE/>

</AAA> XPath expression:/aaa/eee|//ddd/ccc| AAA|//BBB Merge No Limits

Http:www.w3school.com.cn/xpath/index.asp

Html/xml/xpath Foundation

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.