Answer the question
In order to leave comments, you need to log in
What is my mistake (parser)?
Hello, I'm trying to parse an xml file:
<?xml version="1.0" encoding="utf-8" ?>
<xmlDoc>
<document quantity="1">
<reader>
<entry>AB:ГОРОДСКОЙ ЧИТАТЕЛЬ</entry>
<entry>AA:5502d0933967dc713dea44699088b0cf</entry>
</reader>
<list>
<entry codePlace="B001" place="Библиотека" total="1" />
</list>
</document>
</xmlDoc>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$xml = simplexml_load_file('index.xml');
foreach ($xml->reader->entry as $entry) {
echo $entry . '<br>';
}
Answer the question
In order to leave comments, you need to log in
foreach ($xml->document->reader->entry as $entry) {
echo $entry."\n" ;
}
$xml->reader->entry
you accessed an empty value and as a result an error in the future, just check what you pass to the print_r / var_dump loop
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question