<bakery name="DELICIOUS ART Cafe">
<cupcakes category="mini">
<name>Dazzling Choc</name>
<flavour>chocolates</flavour>
<filling>blueberry</filling>
<price>1.50></price>
</cupcakes>
<muffin>
<name>SweetAndCruncy</name>
<flavour>vanilla</flavour>
<filling>mixed fruits</filling>
<price>2.00></price>
</muffin>
<cupcakes category="medium">
<name>SweetAndSour</name>
<flavour>orange</flavour>
<filling>chocolates</filling>
<price>2.50></price>
</cupcakes>
<muffin>
<name>Melting Valcano</name>
<flavour>vanilla</flavour>
<filling>chocolates</filling>
<price>1.80></price>
</muffin>
</bakery>
Write the XPATH expression for the following instructions
a) Select all mini cupcakes.
/bakery/cupcakes or //cupcakes
b) Select all flavour for muffin.
/bakery/muffin/flavour or //muffin/flavour
c) Select the name and price of all muffins.
//muffin/name|//muffin/price
d) Select names of cupcakes where the price is less than RM2.00
//cupcakes[price<2.00]
e) Select all cupcakes and muffin that have chocolates as filling.
/bakery/*[filling='chocolates']
Question 2 :
=========================================
<monitors>
<monitor type="LED" modelNo="m0010">
<size>24</size>
<ratio>16:9</ratio>
<launchDate date="2010-04-03"/>
<feature> High contrast Ratio</feature>
<feature> 100% sRGB color space</feature>
<price>1000</price>
</monitor>
<monitor type="LCD" modelNo="m0101">
<size>20</size>
<ratio>16:10</ratio>
<launchDate date="2008-09-10"/>
<feature>Titl, Swivel, High</feature>
<price>250</price>
</monitor>
<monitor type="CRT" modelNo="c0120">
<size>15</size>
<ratio>4:3</ratio>
<launchDate date="2002-05-15"/>
<price>500</price>
</monitor>
</monitors>
nodes:/*/monitor[2]/*[not(@*)] -- without attribute only
nodes:/*/monitor[2]/*[(@*)] --- with attribute only
nodes:/monitors/monitor/feature/parent::* -- with the element 'feature' only
nodes:/*/monitor[contains(feature,'High')]/price
<!--nodes xpath /*/monitor[contains(feature,'High')]/price'-->
<price>1000</price>
<price>250</price>
0 comments:
Post a Comment
Say whut you want, but be responsible on whut you said...