PDA

View Full Version : Convert PHP Object to XML



toskers25
16 May 2011, 02:42 AM
I have a PHP object that I'd like to convert to XML so that I can use SimpleXML to run an xpath on the data.

Can someone suggest some way to do this?

Basically, I have the following PHP object and I need to be able to search for certin nodes and bring back the information in them. The easiest way I could think of was xpath using SimpleXML. I'm open to other ideas.

===========



[folder] => stdClass Object
(
[id] => e105efd28e689c864bfa79c8e0daa32f
[name] => 2011
[parentFolderId] => e103a7ae8e689c864bfa79c80067db40
[parentFolderPath] => career/assets/contest
[path] => career/assets/contest/2011
[lastModifiedDate] => 2011-05-11T21:45:53.339Z
[lastModifiedBy] => admin
[siteId] => 2602291d8e6894cd01e1c66ab23da966
[siteName] => Test
[metadata] => stdClass Object
(
[author] =>
[displayName] =>
[endDate] =>
[keywords] =>
[metaDescription] =>
[reviewDate] =>
[startDate] =>
[summary] =>
[teaser] =>
[title] =>
[dynamicFields] => stdClass Object
(
[dynamicField] => stdClass Object
(
[name] => Navigation Level
[fieldValues] => stdClass Object
(
[fieldValue] => stdClass Object
(
[value] => Undefined
)

)

)

)

)


[children] => stdClass Object
(
[child] => Array
(
[0] => stdClass Object
(
[id] => ea8275118e689c864bfa79c8945ce74b
[path] => stdClass Object
(
[path] => career/assets/contest/2011/test-1.gif
[siteId] => 2602291d8e6894cd01e1c66ab23da966
[siteName] =>
)

[type] => file
[recycled] =>
)

[1] => stdClass Object
(
[id] => eaa50bd28e689c864bfa79c87085ead0
[path] => stdClass Object
(
[path] => career/assets/contest/2011/test-2.gif
[siteId] => 2602291d8e6894cd01e1c66ab23da966
[siteName] =>
)

[type] => file
[recycled] =>
)

)

)

)

)