誰かがこれに似たような質問がたくさんあることを知りたいと思う前に、積み重ねて見つけたすべての方法を試してみました。問題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"
お知らせ:
可能性が非常に高い、*デフォルトの名前空間(* 'のxmlnsは= "http://somesite.co.nzは、"')あなたに問題が発生します。読んでください:http://stackoverflow.com/a/2386706/2998271 – har07