Welcome Guest, Not a member yet? Register   Sign In
trying to get xml value from array
#1

[eluser]rossmurphy[/eluser]
Hi,

I have an array called $xmlresponse and it contains this..

Quote:array(2) { ["xmlresponse"]=> object(SimpleXMLElement)#17 (2) { ["metadata"]=> object(SimpleXMLElement)#18 (1) { ["column"]=> array(4) { [0]=> object(SimpleXMLElement)#20 (1) { ["@attributes"]=> array(2) { ["datatype"]=> string(4) "text" ["name"]=> string(6) "userId" } } [1]=> object(SimpleXMLElement)#21 (1) { ["@attributes"]=> array(2) { ["datatype"]=> string(4) "text" ["name"]=> string(5) "token" } } [2]=> object(SimpleXMLElement)#22 (1) { ["@attributes"]=> array(2) { ["datatype"]=> string(4) "text" ["name"]=> string(13) "authenticated" } } [3]=> object(SimpleXMLElement)#23 (1) { ["@attributes"]=> array(2) { ["datatype"]=> string(4) "text" ["name"]=> string(10) "jsessionid" } } } } ["rows"]=> object(SimpleXMLElement)#19 (1) { ["row"]=> object(SimpleXMLElement)#24 (1) { ["@attributes"]=> array(4) { ["authenticated"]=> string(4) "true" ["jsessionid"]=> string(32) "CAF7D365B6CB63E261B283345BBB3812" ["token"]=> string(32) "p7yPE7zQWWFcYvNI6mD29yHCY7Cb0Bt2" ["userId"]=> string(6) "pleepo" } } } } ["apistring"]=> string(114) "http://192.168.0.42:8081/site-api/login.action?siteId=SITE&key=abc&sessionId=6900635&userId=pleepo&password=pleepo" }

I am using..

Code:
$testvar = $xmlResult->rows->row['authenticated'];

To try and get the value of 'authenticated' from the xml. I am getting an error..

Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/dologin.php

Line Number: 21

anyone know what im doing wrong?

Thanks
#2

[eluser]gtech[/eluser]
.
#3

[eluser]rossmurphy[/eluser]
You posted a blank..
#4

[eluser]gtech[/eluser]
this is how I read it
Code:
$xmlresult['xmlresponse']->rows->row['authenticated'];
assuming $xmlresult is what is var_dumped above, its quite difficult to read the response so its taken me several attempts
#5

[eluser]rossmurphy[/eluser]
Thanks, i got it using
Code:
$xmlResult->rows->row['authenticated']
Smile
#6

[eluser]gtech[/eluser]
lol ok.. I think ive been staring at code far to long... Im going to take a break, as a matter of interest whats the difference between that and your original code you posted?




Theme © iAndrew 2016 - Forum software by © MyBB