For the XML shown, which XPath expression returns exactly one node?
A.
/purchaseOrder/orderDate
B.
/purchaseOrder/items/item[0]/quantity
C.
/purchaseOrder//item
D.
/purchaseOrder//comment[not(following: : description) ]
Explanation:
For the XML shown, which XPath expression returns exactly one node?
A.
/purchaseOrder/orderDate
B.
/purchaseOrder/items/item[0]/quantity
C.
/purchaseOrder//item
D.
/purchaseOrder//comment[not(following: : description) ]
Explanation:
B
B is incorret,
Can you test the xpath in webpage :http://www.xpathtester.com/xpath
with this path and xml:
PATH:
/purchaseOrder/items/item[0]/quantity
(Note: correct = /purchaseOrder/items/item[0]/quantity)
XML:
John Doe
123 Courthouse Square
Hill Valley
CA
PurchaseOrder for Marty Mcfly
Flux capacitor and others
Flux Capacitor
Good one as well
1
1295.00
1.44 jigawatts
Delorean
Good one as well
Nice cat
1
200000.00
2012-05-23
are you agree with me?
Sorry,
B is incorrrect
Can you test xpath in webpage: http://www.xpathtester.com/xpath
whith this xpath y XML:
XPATH:
/purchaseOrder/items/item[0]/quantity
*(note: Correct = /purchaseOrder/items/item[1]/quantity)
XML:
<![CDATA[
John Doe
123 Courthouse Square
Hill Valley
CA
PurchaseOrder for Marty Mcfly
Flux capacitor and others
Flux Capacitor
Good one as well
1
1295.00
1.44 jigawatts
Delorean
Good one as well
Nice cat
1
200000.00
2012-05-23
]]>
(D) is correct:
Can you test: /purchaseOrder//comment[not(following::description) ] in webpage page: http://www.xpathtester.com/xpath
D is correct.
Yes D is Correct.
Correct is D not(following: : description)… easy to test and confirm.
item[0] is incorrect index (index of first element is 1)
B is correct the indexing of number starts with 0, if there are n numbers indexing will be till n-1 elements.
did you actually test item[0] and got an element as responce?!
can you please provide me with example and tell me which IE did you use?
Can you please also check this: http://www.xqueryfunctions.com/xq/fn_index-of.html
D
D
Position in Xpath starts with 1 not from 0
And double “/” (//) means child on any level inside node (including 1 level)
John Doe
123 Courthouse Square
Hill Valley
CA
12104
Purchase Order for bla bla bla
Flux capacitor and others
Flux Capacitor
Good one
1
1295.00
1.44 gjjjgjgg
Deloreaen
Good one as well
Nice car
1
200000.00
2012-05-23
No one of the answeres is fitting, only if /purchaseOrder/items/item[1]/quantity