Dave
Dave

Reputation: 783

PHP Simple XML Element Object - How to get string value

How do I get the values of the follow array fields in php? When I do a print_r function on a two dimensional array, I get the following result:

[title] => SimpleXMLElement Object ( ) [date] => SimpleXMLElement Object ( )

How do I get the string value of title and date? I've tried casting them with

(string)

, however this didn't work.

Upvotes: 0

Views: 563

Answers (1)

glennv
glennv

Reputation: 713

You need to access the attributes of the SimpleXMLElement Object. Say you have an instance named entry with child title you type

(string) $entry->title;

Upvotes: 1

Related Questions