我使用http://www.freeformatter.com/xpath-tester.html在
上获得UserId
值
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:paf="http://paf.mycompany.com/">
<soapenv:Header/>
<soapenv:Body>
<paf:requestpafBean>
<!--Optional:-->
<arg0>
<!--Optional:-->
<UserId>?</UserId>
<!--Optional:-->
<DateNow>?</DateNow>
</arg0>
</paf:requestpafBean>
</soapenv:Body>
</soapenv:Envelope>
测试此XPath表达式:
//paf:UserId[1]/@text
为什么我没有匹配?
答案 0 :(得分:4)
以下XPath表达式
//UserId/text()
将根据要求选择?
。
备注:强>
UserId
没有名称空间,因此您不想要paf:UserId
。UserId
,您可以将UserId[1]
添加到您的text
表达UserId
上没有UserId/@text
属性,因此您不想要text()
,但UserId
下方有UserId/text()
个节点,所以你确实想要UserId
。string(//UserId)
下可能有进一步的标记,您可能需要其字符串
值{
"body": {
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [
{
"credit_card": {
"first_name": "dfgdfg",
"billing_address": {
"phone": "435435435",
"postal_code": "54343",
"line1": "******",
"country_code": "AU",
"city": "rtytr"
},
"expire_month": 3,
"number": "xxxxxxxxxxxx4545",
"last_name": "dfgdfg",
"cvv2": "***",
"expire_year": 2021,
"type": "visa"
}
}
]
},
"transactions": [
{
"invoice_number": "#",
"amount": {
"currency": "USD",
"total": "235.00",
"details": {
"subtotal": "235.00",
"tax": "0.00",
"shipping": "0.00"
}
},
"description": "descr...",
"item_list": {
"items": [
{
"sku": "sku",
"currency": "USD",
"price": "235.00",
"name": "Credits 5",
"quantity": "1"
}
]
}
}
]
},
"header": {
"x-pp-ads-performed": "false",
"content-length": "624",
"paypal-request-id": "44eae10f-64cb-43e6-b77e-74XXXXX56338",
"x-pp-silover": "name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dplatformapiserv%26TIME%3D4228306518",
"accept": "*/*",
"client-auth": "No cert",
"authorization": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmRN4",
"host": "api.sandbox.paypal.com",
"user-agent": "PayPalSDK/PayPal-NET-SDK 1.7.3 (lang\\u003dDOTNET;v\\u003d4.5.1;clr\\u003d4.0.30319.42000;bit\\u003d64;os\\u003dMicrosoft Windows NT 6.2.9200.0)",
"x-slr-orig-script_uri": "https://api.sandbox.paypal.com/v1/payments/payment",
"x-pp-corrid": "2d94a472d94a2",
"pp_remote_addr": "XXX.XXX.XXX.XXX",
"content-type": "application/json",
"x-pp-slingshot-targetapp": "platformapiserv"
},
"additional_properties": {},
"method": "POST"
}
,而不是选择其子文本节点。