我有下面的XML:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<LogonResponse xmlns="http://schemas.navitaire.com/ClientServices/Common/SessionManagerClient">
<LogonResult>
<LastName xmlns="http://schemas.navitaire.com/Messages/Session/Response">Mont</LastName>
<FirstName xmlns="http://schemas.navitaire.com/Messages/Session/Response">Paul</FirstName>
<PersonID xmlns="http://schemas.navitaire.com/Messages/Session/Response">123</PersonID>
<CultureCode xmlns="http://schemas.navitaire.com/Messages/Session/Response">en-US</CultureCode>
<CurrencyCode xmlns="http://schemas.navitaire.com/Messages/Session/Response">Dollar</CurrencyCode>
<LastLogon xmlns="http://schemas.navitaire.com/Messages/Session/Response">0001-01-01T00:00:00</LastLogon>
<SessionContext xmlns="http://schemas.navitaire.com/Common">
<SessionControl>OneOnly</SessionControl>
<SystemType>Default</SystemType>
<SessionID>0</SessionID>
<SequenceNumber>0</SequenceNumber>
<MessageVersion>0</MessageVersion>
<Signature>00000000-0000-0000-0000-000000000000</Signature>
<ChannelType>Default</ChannelType>
<InTransaction>false</InTransaction>
<TransactionDepth>0</TransactionDepth>
<TransactionCount>0</TransactionCount>
<SecureToken>kFBOdZGqP6s=|/TftALE31236mSppQoFpArBizzz=</SecureToken>
</SessionContext>
</LogonResult>
</LogonResponse>
</s:Body>
</s:Envelope>
这个想法是将 SecureToken、Signature 和 MessageVersion 抓取到变量中,我正在尝试使用下面的代码:
SecureToken = tree.find('.//SecureToken').text
但是没有运气,我需要使用所有的命名空间或其他东西来实现这一点?
请记住,此 XML 是来自请求的返回,我无法对其进行编辑。