PHP - transform value from XML field to HTML field with elements which is repeating?

reerfanty

New Member
I have xml field \[code\]$xmlstring\[/code\] with value;\[code\]'<result> <customerAccount xmlns="http://www.ibm.com> <AccountStatus xmlns="">Due</AccountStatus> <ComponentCustomerAccount xmlns=""> <Name>ADSL</Name> <CharacteristicValue> <Characteristic> <Name>Balance</Name> </Characteristic> <Value>0.0</Value> </CharacteristicValue> <CharacteristicValue> <Characteristic> <Name>Date</Name> </Characteristic> <Value>21.10.1990</Value> </CharacteristicValue> <AccountStatus>Active</AccountStatus> </ComponentCustomerAccount> <ComponentCustomerAccount xmlns=""> <Name>IPTV</Name> <CharacteristicValue> <Characteristic> <Name>Balance</Name> </Characteristic> <Value>100</Value> </CharacteristicValue> <CharacteristicValue> <Characteristic> <Name>Date</Name> </Characteristic> <Value>21.10.1990</Value> </CharacteristicValue> <AccountStatus>Active</AccountStatus> </ComponentCustomerAccount> </customerAccount></result>';\[/code\]I want to display in HTML field within table:\[code\]NAME STATUS VALUEADSL ACTIVE 0.0IPTV ACTIVE 100\[/code\]As you can see I have some elements which are repeating.ComponentCustomerAccount is repeating and I can have multiple elements.I do not need first AccountStatus element but I need AccountStatus element within ComponentCustomerAccount.Also I need first element Name within ComponentCustomerAccount element.\[code\] $xml = new SimpleXMLElement($xmlString); $html = "<table>"; $html .= "<tr><th>Account Name</th><th>Status</th><th>Amount</th></tr>"; foreach($xml->customerAccount as $cust) { $html .= "<tr><th>" . $cust->Name . "</th><th>" . $cust->AccountStatus. "</th><th>" . $cust->Value . "</th></tr>"; } $html .= "</table>";\[/code\]But I am getting blank output.What do I have to change?Thank you
 
Back
Top