0

Possible Duplicate:
Able to see a variable in print_r()'s output, but not sure how to access it in code

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
                            (
                            )

                    )

            )

    )

)

i want to fetch username , password and succeeded from the above array

Community
  • 1
  • 1
Anand
  • 21
  • 7

3 Answers3

1

Do you mean:

$username = (string) $xml->Body["CreateUserResponse"]->username;
$password = (string) $xml->Body["CreateUserResponse"]->password;
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
1

Well i am going out on a limb here, but it might be something like:

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

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

SoWhat
  • 5,564
  • 2
  • 28
  • 59
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;


                            }
                   }
    }
Anand
  • 21
  • 7