which XPath expression returns exactly one node?

View the Exhibit.

For the XML shown, which XPath expression returns exactly one node?

View the Exhibit.

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:



Leave a Reply 12

Your email address will not be published. Required fields are marked *


Freddy Lemus

Freddy Lemus

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?

Freddy Lemus

Freddy Lemus

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

]]>

R

R

Yes D is Correct.

toBe

toBe

Correct is D not(following: : description)… easy to test and confirm.
item[0] is incorrect index (index of first element is 1)

Harish

Harish

B is correct the indexing of number starts with 0, if there are n numbers indexing will be till n-1 elements.

azonium

azonium

D

Position in Xpath starts with 1 not from 0
And double “/” (//) means child on any level inside node (including 1 level)

qwerty

qwerty

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