This is an example xml which i need to access its elements. In this example, I need to perform a loop to add another -> to move to another element. I will get values from XML not generate an XML
<Person>
<Address>
<State>
<Code>101</Code>
</State>
</Address>
</Person>
<Person>
<Address>
<State>
<Code>101</Code>
</State>
<Phone> 123456789</Phone>
</Address>
</Person>
Code:
for($i=0; $i< count(Person); $i++)
{
$element .= '->{<<element>>['.$i.']}';
}
//output would something be like an element to get data from XML: `
$person->{'Address'}->{'State'}->{'Code'};`