0

可能重复:
能够在 print_r() 的输出中看到一个变量,但不确定如何在代码中访问它

SimpleXMLElement Object

(
[Header] => SimpleXMLElement Object
    (
    )

[Body] => SimpleXMLElement Object
    (
        [CreateUserResponse] => SimpleXMLElement Object
            (
                [username] => anup_165
                [password] => xnrrtgohgv
                [result] => SimpleXMLElement Object
                    (
                        [succeeded] => true
                        [errorCode] => 0
                        [errorText] => SimpleXMLElement Object
                            (
                            )

                    )

            )

    )

)

我想从上面的数组中获取用户名、密码并成功

4

3 回答 3

1

你的意思是:

$username = (string) $xml->Body["CreateUserResponse"]->username;
$password = (string) $xml->Body["CreateUserResponse"]->password;
于 2012-07-20T11:39:25.673 回答
1

好吧,我在这里四处走动,但可能是这样的:

$object['body']['CreateUserResponse']['username']   


$object['body']['CreateUserResponse']['password']

于 2012-07-20T11:39:54.403 回答
0
    //For Parsing the xml 
    $xmltoaparse=simplexml_load_string($xmlresponse);


    foreach($xmltoaparse->children() as $iasorecord)
    {

             foreach($iasorecord as $iasouserrecord)  //for each for machhnia attributes
                   {
                        foreach($iasouserrecord as $iasousersrecord)  //for each for machhnia attributes
                            {

                echo $iasousersrecord->getName();
                echo    $iasousersrecord;


                            }
                   }
    }
于 2012-07-20T12:08:18.290 回答