0

I have this output when reading an XML file.

http://pastebin.com/NfNHBaHt

SimpleXMLElement Object
(
    [GetAllDomains] => SimpleXMLElement Object
        (
            [DomainDetail] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [DomainName] => domain1.com
                            [DomainNameID] => 153033597
                            [expiration-date] => 3/1/2017 2:23:56 PM
                            [lockstatus] => Locked
                            [AutoRenew] => Yes
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [DomainName] => domain2.com
                            [DomainNameID] => 153043233
                            [expiration-date] => 5/25/2017 5:45:00 PM
                            [lockstatus] => Not Locked
                            [AutoRenew] => Yes
                        )

                )

            [domaincount] => 2
            [UserRequestStatus] => DomainBox
        )

    [Command] => GETALLDOMAINS
    [APIType] => API
    [Language] => eng
    [ErrCount] => 0
    [ResponseCount] => 0
    [MinPeriod] => SimpleXMLElement Object
        (
        )

    [MaxPeriod] => 10
    [Server] => SJL0VWRESELL_T1
    [Site] => eNom
    [IsLockable] => SimpleXMLElement Object
        (
        )

    [IsRealTimeTLD] => SimpleXMLElement Object
        (
        )

    [TimeDifference] => +0.00
    [ExecTime] => 0.094
    [Done] => true
    [RequestDateTime] => 5/25/2015 9:47:21 AM
    [debug] => SimpleXMLElement Object
        (
        )

)

the above output is being shown by using the print_r function in PHP

how can i loop through the array of DomainDetail in PHP using a foreach loop

i tried using print_r($xml->DomainDetail); and print_r($xml["DomainDetail"]);

but nothing is being shown using this print_r

1

1 Answer 1

1
foreach($xml->GetAllDomains->DomainDetail as $domainDetail) {
    echo $domainDetail->DomainName, "\n";
    echo $domainDetail->DomainNameID, "\n";
    echo $domainDetail->{'expiration-date'}, "\n";
    // etc..
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.