<People>
<Name Age="26" Gender="M">John</Name>
<Status>Single</Status>
<Occupation>Accountant</Occupation>
</People>
<People>
<Name Age="31" Gender="M">David</Name>
<Status>Married</Status>
<Occupation>Engineer</Occupation>
<Children>
<Name Gender="M">Ryan</Name>
<Name Age="5" Gender="F">Peggy</Name>
</Children>
</People>
</Peoples>
| Root | /Peoples |
| Name | /Peoples/People/Name or //People/Name (John, David) //Name or //*[name()='Name'] (John, David, Ryan, Peggy) //People/Children/Name or //Children/Name (Ryan, Peggy) |
| Status | /Peoples/People/Status or //Status or //*[name()='Status'] (Single, Married) |
| Descendent of people | //People/descendant::* (John Single Accountant David Married Engineer Ryan Peggy) |
| All Element | /* |
| Name with 3 ancestor | /*/*/*/Name (Ryan, Peggy) |
| Name with 2 ancestor | /*/*/Name (John, David) |
| First //People/Status | //People/Status[1] (Single) |
| First //Children/Name | //People/Children/Name[1] (Ryan) |
| Second //People/Name | //People/Name[2] (David) |
| Last //People/Status | //People/Status[last()] (Married) |
| Age attribute | //@Age (26,31,5) //Name[@Age] (John, David, Peggy) //Name[@Age='31'] (David) //Name[@Gender='M'] (John,David) |
| All attribute | //@* (26 M,31 M,M,5 F) |
| No Age attribute | //Name[not(@Age)] (Ryan) |
| Element with 3 descendent | //*[count(*)=3] <People> <Name Age="26" Gender="M">John</Name> <Status>Single</Status> <Occupation>Accountant</Occupation> </People> |
| Name and Status | //Name | //Status (John Single, David Married, Ryan, Peggy) |
| Select ancestors | //Children/ancestor::* People & Peoples |
| Following sibling | //Name/following-sibling::* Status & Occupation & Children (Single Accountant,Married Engineer Ryan Peggy) |
| Preceding sibling | //Occupation/preceding-sibling::* Name & Status (John Single, David Married) |



0 comments:
Post a Comment