Проблемы с SimpleXml при доступе к узлам xml - PullRequest
1 голос
/ 26 июля 2010

У меня серьезные проблемы с доступом к узлам определенного XML-файла:

http://write.fm/cqsmrf5

с print_r я получаю следующий результат:

SimpleXMLElement Object
(
    [RecordSet] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [dataSource] => testdatabase
                    [totalRecordCount] => 3573
                )

            [Record] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [counter] => 1
                                )

                            [Fields] => SimpleXMLElement Object
                                (
                                    [Field] => Array
                                        (
                                            [0] => Barcelona
                                            [1] => 1
                                        )

                                )

                        )

                    [1] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [counter] => 2
                                )

                            [Fields] => SimpleXMLElement Object
                                (
                                    [Field] => Array
                                        (
                                            [0] => Cádiz
                                            [1] => 2
                                        )

                                )

                        )

                )

        )

Я пытался получить доступ через команду печать $xml->recordset->record[0]->fields->field[0]; Но я получаю только ошибку:

Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/test.php on line 18

Может ли кто-нибудь помочь мне. Заранее спасибо.

1 Ответ

2 голосов
/ 26 июля 2010

XML чувствителен к регистру .Попробуйте

$xml->RecordSet->Record[0]->Fields->Field[0]; // Barcelona
...