The expression:
shipping[@cost]
will return a <shipping>
element (node), not any attribute string. The [...]
is a predicate which is used to select a certain node. It says: "select the shipping
element which contains a cost
attribute". So you are actually selecting the same node in both expressions.
Since you only have one shipping
element in your $node
context don't need any predicates.
To actually select an attribute you need to add an extra step:
shipping/@cost
shipping/@carrier