在有人指出類似這樣的類似問題之前,請記住我已經嘗試並用盡了所有可以在堆疊中找到的方法。在使用simplexml之後訪問XML時遇到問題
我在使用simplexml從結構如下的響應中抽出我想要的數據時遇到了問題。
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:body>
<authenticateresponse xmlns="http://somesite.co.nz">
<authenticateresult>
<username>Username</username>
<token>XXXXXXXXX</token>
<reference>
<message>Access Denied</message>
</reference>
</authenticateresult>
</authenticateresponse>
</soap:body>
在這種情況下,我想知道如何取出令牌和用戶名。
很有可能,*默認命名空間*('的xmlns = 「http://somesite.co.nz」')使你的問題。閱讀:http://stackoverflow.com/a/2386706/2998271 – har07